Can anyone explain why this code results in the below output?
@Test
public void testBooleanArray() {
Boolean[] ab = new Boolean[]{a, b};
a = new Boolean(true);
b = new Boolean(false);
for(Boolean x : ab) {
System.out.println(x);
}
}
Result:
null
null
Should the array ab not holds pointers to object a and object b, and therefore output:
true
false