public class S_eaqual {
public static void main(String[] args) {
String s1 = "one", s2 = "two";
if (s1 + s2 == "onetwo") {
System.out.println("Yes..equal");
}
}
}
This type of comparison shows errors. Is this not the right way of comparing strings?
Two String
objects can be compared using ==
operator. So why this is showing error?
No comments:
Post a Comment