String comparision example
Join the DZone community and get the full member experience.
Join For Freepackage com.pk.com;
public class Example {
public static void main(String[] args) {
String s = "abc";
String s2 = "abc";
String s3 = new String("abc");
if (s == s2)
System.out.println("true");
else
System.out.println("false");
if (s.equals(s2))
System.out.println("true");
else
System.out.println("false");
if (s == s3)
System.out.println("true");
else
System.out.println("false");
if (s.equals(s3))
System.out.println("true");
else
System.out.println("false");
}
}
Strings
Data Types
Opinions expressed by DZone contributors are their own.
Comments