-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringBufferTest.java
More file actions
28 lines (19 loc) · 714 Bytes
/
StringBufferTest.java
File metadata and controls
28 lines (19 loc) · 714 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
package string;
public class StringBufferTest {
public static void main(String[] args) {
String str = "one string data";
char c = str.charAt(1);
System.out.println(str + "\n");
System.out.println("char at 1: " + c);
StringBuffer strBuff = new StringBuffer(str);
System.out.println("Position 0 is replaced with 1");
strBuff.setCharAt(0, '1');
System.out.println(strBuff);
char[] charBuffer = new char[6];
strBuff.getChars(4, 10, charBuffer, 0);
System.out.println("Content of chaBuffer: " + new String(charBuffer));
String url = "www.bbc.com";
String updatedUrl = url.replaceAll("[,\\.]+", "+");
System.out.println(updatedUrl);
} // end of main()
} // end of stringBufferTest