|
发表于 2005-7-26 10:51:34
|
显示全部楼层
String的赋值方式比较特殊,以下文字选自《The JavaTM Tutorial》:
Because the compiler automatically creates a new string object for every literal string it encounters, you can use a literal string to initialize a string:
String s = "Hola Mundo";
The preceding construct is equivalent to, but more efficient than, this one, which ends up creating two identical strings:
String s = new String("Hola Mundo"); //don't do this
可见语句str_1="111";编译器其实上将它翻译成str_1=new String("111"); |
|