We all know that ‘==’ operator check for Object reference equality. It’s not supposed to compare values. That is why I was bugged when I tried the code below and got the ‘impossible output’. Can you tell me why?
package com.twisters;
class IntegerEquality{
public static void main(String args[]){
Integer first = 100;
Integer second = 100;
if(first == second)
System.out.println(“This is impossible!!”)
else
System.out.println(“Everything is as expected out here.”)
}
}
No comments:
Post a Comment
Solution for this question?