How to compare String instances
class MainClass { public static void main(String[] args) { String s1 = "abc"; String s2 = "abc"; String s3 = "def"; if (s1 == s2) System.out.println("s1 == s2"); if (s1 != s3) System.out.println("s1 != s3"); if (s2 != s3) System.out.println("s2 != s3"); String s4 = s1.toUpperCase(); if (s4 != s1) System.out.println("s4 != s1"); System.out.println("s1 = " + s1); System.out.println("s4 = " + s4); } }