Following code:
String a = new String("aaa");
String a2 = new String("aaa");
System.out.println(a == a2);
String b = "bbb";
String b2 = "bbb";
System.out.println(b == b2);
Produces following output:
false
true
Why there is difference in output for comparision a==a2 and b==b2 depending from type of String creation ?