1  import java.text.*;
 2   public class Gxjun
 3  {
 4     public static void main(String atgs[])
 5     {
 6        StringBuffer str= new StringBuffer(); 
 7        str.append("大家好");
 8        System.out.println("str:"+str);
 9        System.out.println("length:"+str.length());  
10        System.out.println("capacity:"+str.capacity());       
11        str.setCharAt(0,'w');
12        str.setCharAt(1,'e');
13        System.out.println(str);
14        str.insert(2, "are all");
15        System.out.println(str);
16        int index=str.indexOf("好");
17        str.replace(index, str.length(),"right");
18        System.out.println(str); 
19     }
20  }
View Code

相关文章:

  • 2021-07-12
  • 2022-01-10
  • 2021-06-24
  • 2021-06-18
  • 2021-10-01
  • 2021-07-29
  • 2021-12-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
相关资源
相似解决方案