StringBuffer 와 String 의 예

2079 단어 StringBuffer
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 +"and"); //string    ,goodand

     System.out.print(ex.ch);//gbc

     //        :goodandgbc

     change2(sbf);

     System.out.println(sbf); //sbf   

  }

 

  public void change(String str, char ch[]){

     str= "test ok";

     ch[0]= 'g';

  }

  public static void change2(StringBuffer sbf)

  {

      sbf.append("333");

  }

}

좋은 웹페이지 즐겨찾기