Skip to content
Onsite

Output: comparing two Integer objects with == for 127 and for 128

EasyP2Output

What does this Java code print?

Integer a = 127, b = 127;
Integer c = 128, d = 128;

System.out.println(a == b);
System.out.println(c == d);
System.out.println(c.equals(d));
Saved automatically

Hints

Write or say your answer first, then compare it with the model answer.

Saved automatically