I have been having a bit of an issue with creating an Array of Objects and then setting the variables for each object. I create the array and then loop through the array setting the variables but it seems each time I loop through it overwrites all previous variables.
It seems like a basic piece of code and a very irregular bug...
public class Test{
Bubble[] bubble = new Bubble[2];
public static void main(String[] args)
{
bubble = new Bubble[2];
bubble[0] = new Bubble();
bubble[0].setDegree(360);
bubble[1] = new Bubble();
bubble[1].setDegree(180)
System.out.println(bubble[0].printDegree());
System.out.println(bubble[1].printDegree());
}
}
That is the basics of it, the other class merely sets up variables and assigns values to them using "bubble[i].setDegree(int);"
The output of the progam gives me:
180
180
What I should be getting is:
360
180
I don't know if I am just rusty and missing something completely obvious or something is going terribly wrong.
bubble) from a static method.N y rmakes no sense to me, even as a native English speaker. I dread to think how incomprehensible it would be for someone who has English only as a second or third language.