How many String object..?

前端 未结 6 1335
礼貌的吻别
礼貌的吻别 2021-01-18 13:36

Me and my friend was discussing on Strings and we stuck on this:

String str = \"ObjectOne\"+\"ObjectTwo\";

He says total three Object will

6条回答
  •  不思量自难忘°
    2021-01-18 14:38

    If you write(literals or constants)

    String str = "ObjectOne"+"ObjectTwo";
    

    it's equivalent to

    String str = "ObjectOneObjectTwo"; // compiler optimize it so one Object
    

提交回复
热议问题