<pre>
public class Boxing6 {
public static void main(
String[] args) {
Boolean b1 = new Boolean(true);
Boolean b2 = new Boolean(true);
boolean b3 = true;
Boolean b4 = true;
System.out.println(b1==b2);
System.out.println(b1==b3);
System.out.println(b3 == b4);
System.out.println(b1 == b4);
}
}
</pre>
What is the output for the above program?
1)false true true false
2)false false false false
3)true true true true
4)false false true true
1 is the answer. I have a fairly good understanding of autoboxing and using the object from the pool.
if b1 and b4 are not equal, they are pointing to different objects, which is fine. How b1 == b3 and b3 == b4 both return true?
Thanks for your help.