No doubt. You should be one of ‘The One’ if you can answer the output correctly……
class Integer {
public static void main(final String args[]) {
final java.lang.Integer a = 127;
final java.lang.Integer b = 127;
System.out.println(a == b); // output 1
final java.lang.Integer c = 128;
final java.lang.Integer d = 128;
System.out.println(c == d); // output 2
// output 1 != output 2 ---- TRUE
}
}
Looks tricky... Sheep is in Integer.valueOf() method... Can anyone explain this?
4 comments:
Dude How Dude why the 128 is not returning true????
Ha ha that's the Beauty. Integer offset range playing the role. Let me know I can explain it you.
explain it plz
Hi Anonymous, Thanks for dropping here. 128 is the offset value which defined in valueOf() method. You will understand if you see the Integer.valueOf() API. Let me know then also you didn't get the point. I can explain you with nice example.
Post a Comment