/** * String equality is possibly confusing! * @author gtowell * Created: Feb 2021 */ public class StringEqual { public static void main(String[] args) { String str1 = new String("one"); String str2 = str1; System.out.println("str1==str2: " + str1 == str2); //"str1==str2: one" System.out.println("str1==str2: " + (str1 == str2)); System.out.println("str1.equals(str2): " + str1.equals(str2)); int fi = 5; int fiv = 5; System.out.println(fi == fiv); } }