java - Why Comparison Of two Integer using == sometimes works and sometimes not? -
this question has answer here:
i know comparing reference while i'm using == not idea did not understand why happening.
integer a=100; integer b=100; integer c=500; integer d=500; system.out.println(a == b); //true system.out.println(a.equals(b)); //true system.out.println(c == d); //false system.out.println(c.equals(d)); //true
the java language specification says wrapper objects @ least -128 127 cached , reused integer.valueof(), implicitly used autoboxing.
Comments
Post a Comment