nofollow">http://www.cnblogs.com/A_ming/archive/2010/04/13/1711395.html
<p style="font-family:Verdana,Arial,Helvetica,sans-serif;">
<span style="font-size:14px;">最近学习到StringBuffer,心中有好些疑问,搜索了一些关于String,StringBuffer,StringBuilder的东西,现在整理一下。
<p style="font-family:Verdana,sans-serif;">
<span style="font-size:14px;">关于这三个类在字符串处理中的位置不言而喻,那么他们到底有什么优缺点,到底什么时候该用谁呢?下面我们从以下几点说明一下
<p style="font-family:Verdana,sans-serif;">
<span style="font-size:14px;"> 1.三者在执行速度方面的比较:<span style="color:#FF0000;">StringBuilder > StringBuffer >
String
<p style="font-family:Verdana,sans-serif;">
<span style="font-size:14px;"> 2.<span style="color:#FF0000;">String <(StringBuffer,StringBuilder)的原因
<p style="font-family:Verdana,sans-serif;">
<span style="font-size:14px;"> String:字符串常量
<p style="font-family:Verdana,sans-serif;">
<span style="font-size:14px;"> StringBuffer:字符创变量
<p style="font-family:Verdana,sans-serif;">
<span style="font-size:14px;"> StringBuilder:字符创变量
<p style="font-family:Verdana,sans-serif;">
<span style="font-size:14px;"> 从上面的名字可以看到,String是“字符创常量”,也就是不可改变的对象。对于这句话的理解你可能会产生这样一个疑问 ,比如这段代码:
<div class="cnblogs_code" style="border:1px solid rgb(204,204,204);overflow:auto;font-family:'Courier New' !important;">