-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStringBufferTest.java
More file actions
41 lines (28 loc) · 849 Bytes
/
Copy pathStringBufferTest.java
File metadata and controls
41 lines (28 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package java_base;
public class StringBufferTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
StringBuffer bf1 = new StringBuffer();
System.out.println(bf1.length());
System.out.println(bf1.capacity());
bf1.append("1234");
System.out.println(bf1.length());
System.out.println(bf1.capacity());
System.out.println(bf1);
StringBuffer bf2 = new StringBuffer("0123456789");
System.out.println(bf2.length());
System.out.println(bf2.capacity());
System.out.println(bf2.toString());
bf2.reverse();
System.out.println(bf2.toString());
bf1.append(bf2);
System.out.println(bf1);
bf1.insert(5, "abc");
System.out.println(bf1);
bf1.delete(5, 8);
System.out.println(bf1);
bf1.replace(3, 7, "XYJ");
System.out.println(bf1);
System.out.println();
}
}