Concat an integer to a String - use String literal or primitive from performance and memory point of view?

前端 未结 5 1475
夕颜
夕颜 2020-12-17 19:34

Option 1:

String newStr = someStr + 3 + \"]\";

Option 2:

String newStr = someStr + \"3\" + \"]\";

Which o

5条回答
  •  感情败类
    2020-12-17 19:48

    I would recommend Jprofiler as a great java application profiling tool that helped me find lots of memory problems.

    I don't think option 1 and 2 have a big difference in terms of memory usage, especially if it is for a desktop application.

提交回复
热议问题