public class Equalsoperator {
public static void main(
String args[]) {
Integer i = new Integer(5);
Integer j = new Integer(5);
if (i==j)
System.out.println ("True");
}
}
The above code prints true irrespective of whether i use the == operator or the equals method. Why is this?
I thought the operator "==" was supposed to do a comparision of the references and the equals method was supposed to do a comparision of the values. Is my assumption wrong?