I don't understand why this works and I hope somebody can explain it to me. Here is an example:
TestObject array[] = new TestObject[10];
for(int i= 0; i <= 10; i++){
TestObject object = new TestObject();
object.setValue(i);
array[i] = object;
System.out.println(array[i].getObject());
}
Why can I create multiple instances of "TestObject" with the same name in the loop? Usually you can't create instances with the same name:
TestObject o = new TestObject(1);
TestObject o = new TestObject(2);
Well, this will obviously throws an error...