String s = new String(“xyz”). How many objects has been made after this line of code execute?

前端 未结 20 2990
再見小時候
再見小時候 2020-11-27 02:45

The commonly agreed answer to this interview question is that two objects are created by the code. But I don\'t think so; I wrote some code to confirm.

publi         


        
20条回答
  •  春和景丽
    2020-11-27 03:15

    I ran it in the Eclipse debugger. In that context, two objects are created, one with the id 17, the other 22:

    enter image description here

提交回复
热议问题