No,
Integer
is a primitive - a value type rather than a reference type.
Introduction to Java Primitives | Baeldung[
^]
So the == operator compares the content, not the reference, because there is no reference to a primitive!
You can prove this very easily:
Integer a1=4;
Integer a2=a1;
System.out.println(a1==a2);
a1++;
System.out.println(a1==a2);
a1--;
System.out.println(a1==a2);
If
a1
and
a2
had the same reference, you would get
true
,
true
,
true
, not
true
,
false
,
true
.