so I have tried searching for the answer to this question, but really don't know exactly how to find my answer. I am trying to insert values into an array, whose elements i declared previously in the same class. It does not work as far as I can tell. The element will change, but not the original variable the element represents. Is this because they are not the same variable (the array makes a copy or something? I hope this makes sense, but if not here is some sample code:
public class bucky {
public static void main(String args[]) {
tuna tunaObject = new tuna();
tunaObject.assignArray(25);
}
}
.
public class tuna {
int day;
int month;
int year;
int dateArray[] = {day, month, year};
void assignArray(int dayInput){
dateArray[0] = dayInput;
System.out.println(dateArray[0]);
System.out.println(day);
}
}
The output is: 25 0
So clearly day does not get altered. Though I wish it would, and wonder how I can make this work.
Unfortunately it's late. I've been working at this for hours. I'm tired. And I'm pretty sure the clocks just rolled back an hour on me.... Knowing the answer to why this doesn't work would make it all worth while. Cheers!