Literal string creation vs String object creation
问题 How many String object are created I am studying for the SCJP I cant seem to get my head round this String problem. I seem to see several possible answers depending on how i look at a question. In the following initialization, how many string objects are created? String s1 = "A" + "B" + "C" + "D"; System.out.println(s1) Initially i thought 5 objects, i.e. "A" "B" "C" "D" "ABCD" But then thinking about it i am not really sure because for example will the compiler concatenate "A" + "B" as one