Can somebody explain why the result is false here. 1: if( new Boolean("true") == new Boolean("true")) 2: System.out.println("True"); 3: else 4: System.out.println("False"); A) Compilation error. B) No compilation error, but runtime exception. C) Prints "True". D) Prints "False".
new Boolean("true") creates a new object. so we have two objects. == tests whether the two operands point to the same object, which is not the case. but equals would return true. hope it helps