mardi 3 mars 2015

Number of objects in string pool

How many string objects does the following code snippet generate in the string pool at runtime:



public class Test {
public static void main(String[] args) {
String string = new String("abc");
System.out.println("abc" == "def");
}
}


Does the second line generate a string object for def? Or is it ignored due to compiler optimization?


Aucun commentaire:

Enregistrer un commentaire