-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringConstructors.java
More file actions
33 lines (26 loc) · 851 Bytes
/
Copy pathStringConstructors.java
File metadata and controls
33 lines (26 loc) · 851 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
public class StringConstructors {
public static void main(String[] args) {
//CONSTRUCTOR 1
String s = new String();
System.out.println(s);
//CONSTRUCTOR 2
String s1= new String("String");
System.out.println(s1);
//CONSTRUCTOR 3
StringBuffer sb= new StringBuffer("String Buffer");
String s2= new String(sb);
System.out.println(s2);
//CONSTRUCTOR 4
StringBuilder sb1= new StringBuilder("String Builder");
String s3= new String(sb1);
System.out.println(s3);
//CONSTRUCTOR 5
char c[]= {'a', 'e', 'i', 'o', 'u'};
String s4= new String(c);
System.out.println(s4);
//CONSTRUCTOR 6
byte b[]= {39, 15, 31, 42, 35};
String s5= new String(b);
System.out.println(s5);
}
}