mercredi 25 mars 2015

String literal and string Object memory allocation


String abc= new String ("Hello");//will create new instance


and



String abc="Hello";//will not create new instance


When the string is created as literal the value "Hello" will be in the string constant pool and the reference will be in stack , What about the String object.where does its memory allocation happen?


What does the intern() method do?


Which is more efficient?


Aucun commentaire:

Enregistrer un commentaire