Possible Duplicate:
Why are these == but not `equals()`?
why this code will print
true
true
public class Test {
public static void main(String[] args){
String st1 = "abc";
String st2 = "abc";
Integer k1 = 100;
Integer k2 = 100;
System.out.println(st1 == st2);
System.out.println(k1 == k2);
}
}
To compare objects we use method equals(). But why it is ok in this way?
No comments:
Post a Comment