Even if your array holds references to objects, making a variable refer to an entirely different object would not change the contents of the array.
Your code does not modify the object variable a refers to. It makes variable a refer to a different object altogether.
Just like your JavaScript code, the following Java code won't work because, like JavaScript, Java passes references to objects by value:
Integer intOne = new Integer(1);
Integer intTwo = new Integer(2);
Integer[] intArray = new Integer[2];
intArray[0] = intOne;
intArray[1] = intTwo;
/* Make intTwo refer to a completely new object */
intTwo = new Integer(45);
System.out.println(intArray[1]);
/* output = 2 */
In Java, if you change the object referenced by a variable (instead of assigning a new reference to a variable) you get the behavior you desire.
Example:
Thing thingOne = new Thing("funky");
Thing thingTwo = new Thing("junky");
Thing[] thingArray = new Thing [2];
thingArray[0] = thingOne;
thingArray[1] = thingTwo;
/* Modify the object referenced by thingTwo */
thingTwo.setName("Yippee");
System.out.println(thingArray[1].getName());
/* output = Yippee */
class Thing
{
public Thing(String n) { name = n; }
private String name;
public String getName() { return name; }
public void setName(String s) { name = s; }
}