When I execute:
String a = "hello";
String b = "hello";
System.out.println(a==b);
I get output as "true".
But when I run:
String a = new String("hello");
String b = "hello";
System.out.println(a==b);
I get output as "false".
I understand that in the first case, Java makes 'b' point to the same object where 'a' pointed, but why can't it do that in the second case?