String好头疼,谁给分析分析
android开发吧
全部回复
仅看楼主
level 6
liuhaolie 楼主
Stirng s1 = "hello";
String s2 = new String("hello");
String s3 = "hello";
String s4 = new String("hello");
这一共创建了多少个String , 哪个和哪个的内存地址一样呢?
2014年07月02日 13点07分 1
level 12
据我所知,s1和s3地址一样,s1,s2,s4三个内存地址。
2014年07月02日 13点07分 2
level 7
哥们,我觉得是这样的:
Stirng s1 = "hello";
String s2 = new String("hello");
String s3 = "hello";
String s4 = new String("hello");
这几个是笔记题里的老霸王了,具体解释如下:
2014年07月02日 16点07分 3
level 13
^&*%~/¥(+^)@#√。-,;@,!?.-#^0^,所以说s1 s3等等都是指向同一个地址,new出来的都是新的一个地址。
2014年07月02日 16点07分 4
level 11
s1和s3一样并且放在常量池中,s2和s4不一样,对应堆内存中不同地址
2014年07月03日 02点07分 5
1