String and some of the difference between StringBuffer
2008-11-14 18:42
525 查看
1:效率方面:
a:StringBuffer必须通过关键字new出来,StringBuffer的append效率比String的+=的效率要高
b:String是一个final Class ,因此这个类是不能被继承,不能修改这个类,而StringBuffer不是.
2:编程方面:
a:改变StringBuffer和String对象的值的时候StringBuffer直接改变指向的地址中保留的值,而String对象改变的是指向的地址,原来的值不会改变.
c:String类中重新定义了Object对象中的equals这个方法比较的是两个对象的值,而StringBuffer类中并没有重新定义Object 对象的equal方法,比较两个对象的时候比较的是对象的地址.
a:StringBuffer必须通过关键字new出来,StringBuffer的append效率比String的+=的效率要高
b:String是一个final Class ,因此这个类是不能被继承,不能修改这个类,而StringBuffer不是.
2:编程方面:
a:改变StringBuffer和String对象的值的时候StringBuffer直接改变指向的地址中保留的值,而String对象改变的是指向的地址,原来的值不会改变.
c:String类中重新定义了Object对象中的equals这个方法比较的是两个对象的值,而StringBuffer类中并没有重新定义Object 对象的equal方法,比较两个对象的时候比较的是对象的地址.
相关文章推荐
- The differences between String, StringBuffer and StringBuilder
- the difference between ClientID and ID of web control
- what is difference between equals() and contentEquals() of String class?
- What is the difference between ControlStyles.DoubleBuffer and ControlStyles.OptimizedDoubleBuffer?
- the Difference of [Ljava.lang.String And java.lang.String
- What is the difference between SVD and matrix factorization in context of recommendation engine?
- The difference of SE Detail UI between 2.4 and 4.0
- BigDecimal(-)Difference of BigDecimal toString() method between JDK1.4 and above version
- Difference Between String , StringBuilder And StringBuffer Classes With Example : Java
- The difference between equals and == of Java
- Project Manager - the Differences of the Role between Western Countries Company and Chinese Company
- Difference between the Bill of distribution and sourcing rule.
- The difference of overriding between C# and Java
- the differences of DataRelation class between 1.1 and 2.0
- What are some of the differences between using recursion to solve a problem versus using iteration?
- The Difference Between Big Data and a Lot of Data
- the differences of DataRelation class between 1.1 and 2.0
- Linux Kernel: What is the major difference between the buffer cache and the page cache?
- Difference Between String , StringBuilder And StringBuffer Classes
- The differences between capturing and bubbling