StringBuffer

JungSik Heo·2022년 9월 29일
0
post-thumbnail
post-custom-banner
StringBuffer sb = new StringBuffer();  // StringBuffer 객체 sb 생성
sb.append("hello");
sb.append(" ");
sb.append("jump to java");
String result = sb.toString();
System.out.println(result);

위를 String 객체 표현

String result = "";
result += "hello";
result += " ";
result += "jump to java";
System.out.println(result);

insert

StringBuffer sb = new StringBuffer();
sb.append("jump to java");
sb.insert(0, "hello ");
System.out.println(sb.toString());

delete

StringBuffer str = new StringBuffer("Java Oracle");

System.out.println("원본 문자열 : " + str);

 

① System.out.println(str.delete(4, 8));

System.out.println(str.deleteCharAt(1));

System.out.println("deleteCharAt() 메소드 호출 후 원본 문자열 : " + str);
profile
쿵스보이(얼짱뮤지션)
post-custom-banner

0개의 댓글