First thing I want to mentioned is that non zero length arrays are always mutable.And inside the foreach loop
for(MyObject o in objects)
what it does is in each iteration it works as following.
o = objects[0] // first iteration
o = objects[1] // 2nd iteration
But in your case you assign another object to the reference o. Not to the objects in the array.Its simply like following.
ObjeMyObject objects[] = new MyObject[6];
MyObject o = Object[0];
0 = new MyObject();
But your original objects[0] still point to a null object.