analysis:
-
""+1
is constant addition, the highest execution efficiency -
String s= str+"str"
Since string is finally modified, str+"str" is essentially carried out1.创建"str"新对象创建, 2.str+"str"新对象的创建 3.赋值给s
Object-oriented programming, the most resource consuming is the creation and destruction of objects, so its stitching efficiency is the lowest
-
String.valueOf()
Will directly call the type conversion method, the efficiency is in the middle