Java Interview Questions
Explain the difference between following : statement String s=”World”; String s=new String (“world”);
In First Statement assignment operator is used to assign the string .In this case Jvm first check the String pool whether the same vale already available in the String container or not and notify if available, if it is not available then it create another reference to it.
In Second case each and every time it creates a new object of string.