Originally posted by Ana Inna: hello, i came accross the following code: Byte b1 = new Byte("123"); if (b1.toString() == b1.toString()) System.out.println("true"); else System.out.println("false"); } could you tell me why it prints "false"?
This is because the == operator checks whether both strings are in the same memory pool .If u try it with the equals method it will return true i.e if (b1.toString().equals(b1.toString()))