![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java-String
Evanlll
和热爱软件编程的你们一起学习,共同进步!
展开
-
"hello"和new String("hello")的区别
以下两种方式定义了内容为“hello”的字符串:方式一: String s1 = "hello",s2 = "hello";方式二: String s3 = new String("hello"),s4= new String("hello");第一种方式,"hello"为直接数,Java虚拟机把它当作编译时常量,在内存中只会为它分配一次内存,就可以重复使用,s1==s2的结果为t原创 2017-04-25 10:09:06 · 844 阅读 · 0 评论 -
比较String类和StringBuffer类
String类和StringBuffer类的相同点:String类和StringBuffer类都是用来处理字符串。String类和StringBuffer类都提供了length(),toString(),charAt(),subString()方法。String类和StringBuffer类的索引index都是从0开始的。String类和StringBuffer类的不同点:原创 2017-04-25 10:11:10 · 600 阅读 · 0 评论