-
Notifications
You must be signed in to change notification settings - Fork 0
/
String Builder.java
41 lines (29 loc) · 964 Bytes
/
String Builder.java
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 whatever //do not write package name here */
import java.io.*;
import java.util.*;
class GFG {
public static void main (String[] args) {
StringBuilder str = new StringBuilder("ABCD");
str.append("abc"); //ABCDabc
//System.out.println("Content is :" + str);
//StringBuilder str2 = new StringBuilder(10);
//System.out.println(str2.capacity());
//System.out.println(str.charAt(2));
//str.delete(2,5);
//System.out.println(str);
//str.deleteCharAt(2);
//System.out.println(str);
//System.out.println(str.length());
/*
char arr[] = new char[str.length()];
str.getChars(4,7, arr, 4);
System.out.println(str);
for(int i=0; i<7; i++)
System.out.println(arr[i]);
*/
str.setCharAt(3, 'E');
System.out.println(str);
System.out.println(str.substring(0,4));
System.out.println(str.reverse());
}
}