0 votes
in JAVA by
What is the output of below code snippet?

String s1 = new String("abc");

String s2 = new String("abc");

System.out.println(s1 == s2);

1 Answer

0 votes
by
It will print false because we are using new operator to create String, so it will be created in the heap memory and both s1, s2 will have different reference. If we create them using double quotes, then they will be part of string pool and it will print true.
...