public class My {
public static void main(String...args) {
Integer i1 = new Integer("013");
Integer i2 = new Integer(013);
System.out.println(i1 == i2);
System.out.println(i1.equals(i2));
}
}
Constructors of wrapper classes that take String as an argument consider that String as a decimal number. Therefore i1 = 13, i2 = 11.
P.S. In the first case the result will be false even if numbers are equal, because links to different objects are compared - not their values (objects are not added to the pool when new is used).
Login in to like
Login in to comment