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

前端 未结 20 2992
再見小時候
再見小時候 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:32

    There are so many random answers and so I am confident that my interviewer will also be not very sure :) :)

    I researched a lot and found that hashcode is not the memory address and the variables while debugging don't give the memory address. So, those parameters might confuse.

提交回复
热议问题