Java: For-Each loop and references [duplicate]
Java works a little bit different than many other languages. What o is in the first example is simply a reference to the object. When you say o = new MyObject(), it creates a new Object of type MyObject and references o to that object, whereas before o referenced objects[index]. That is, objects[index] itself is … Read more