Compare Strings in Java
public class Test { public static void main(String[] args) { String str1 = “Hello”; String str2 = “Hello”; String str3 = null; if (str1 != null) { System.out.println(str1.equals(str2)); } System.out.println(str1.equals(str3)); } } Output: true false 2. Using the == operator to compare Strings in Java public class Test { public static void main(String[] args) {…
Read More Compare Strings in Java