CSC300 / CSC402: Integers Far from Zero [17/24] Previous pageContentsNext page

Integer x = 3000;
Integer y = 3000;
x=3000, y=3000
                  x==y : false
   Objects.equals(x,y) : true
           x.equals(y) : true
eqi01

Java is using Integer.valueOf(3000) to box the integer. The boxed objects are distinct in memory.

Previous pageContentsNext page