public class Test {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer();
sb.append("안녕);
sb.append(" ");
sb.append("난 kyu!");
System.out.println(sb.toString());
}
}
안녕 난 kyu!
public class Test {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer();
sb.append("난 kyu!");
sb.insert(0, "안녕 ");
System.out.println(sb.toString());
}
}
안녕 난 kyu!
public class Test {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer();
sb.append("안녕 난 kyu!");
System.out.println(sb.substring(0, 4));
}
}
안녕 난
StringBuffer와 사용법이 같음
String | StringBuilder | StringBuffer | |
---|---|---|---|
보관 | String pool | Heap | Heap |
성능 | Fast | Fast | Slow |
스레드 세이프 | YES | NOPE | YES |
Syncronized | YES | NOPE | YES |
Modifiable | Immutable | Mutable | Mutable |