Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  What will the value of Integer.valueOf(127) == Integer.valueOf(127) be in Java?

Do you really understand how Java does the integer comparison? OK, ignore the statements in the post title. What we are interested in is another set of comparison statements. Let's first see below code snippet.public class IntegerComparison { public static void main(String[] args) { Integer a = 127, b = 127; Integer c = 128, d = 128; System.out.println(a == b); System.out.println(c == d); }}What do you think the output will be? Are they both displaying true? You will find out the answer after reading through how Java optimizes some of the integer comparison logic.First, you need to un...

11,153 3       JAVA == EQUALSTO