class Test { public static void main(String[] args) { String a = "tree"; String b = "tree"; System.out.println(a == b); // WRONG System.out.println(a.equals(b)); // Right way to compare objects } }