StringBuffer 与 String

String对象为不可变的常量,在创建后任何引用都无法改变它的值,因此在连接字符串时,将新建String对象存放连接后的字符串,会产生许多无用的中间对象,性能较差。
StringBuffer对象为可变对象,可使用append方法连接字符串,不会新建对象,在处理频繁的字符串连接时更加高效(在JDK1.5后也可使用StringBuilder)。

3 comments to StringBuffer 与 String

发表评论

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

分类目录