public class Example { String str = new String("good"); static StringBuffer sbf=new StringBuffer(); char[] ch = {'a','b','c'}; public static void main(String[] args) { Example ex = new Example(); ex.change(ex.str, ex.ch); System.out.print(ex.str…
在java中我们经常可以看到StringBuffer和String的用法,但是我自己在使用过程中,经常会将两者弄混淆,今天我们就来了解一下两者的区别: 我们首先来看一下我们的官方API中的简单介绍: A string buffer is like a String, but can be modified. At any point in time it contains some particular sequence of characters, but the length and con…