Comparing Strings
String s1, s2;
String s3 = "hello";
s1 = new String("hello");
s2 = new String("hello");
String s4 = s1;
(s1 == s2) // false
(s1 == s3) // false
(s1 == "hello") // false
(s1 == s4) // true
(s1.equals(s2)) //true
(s1.equals(s3)) // true
(s1.equals("hello")) //true
(s3 == "hello") // true
Previous slide
Next slide
Back to first slide
View graphic version