1
+ class b_of_str {
2
+ public static void main (String [] a ){
3
+ String s1 = new String ("New String" );
4
+ System .out .println ("Basic String using new keyword : " + s1 );
5
+
6
+ String const1 = "Constant Value !" ;
7
+ System .out .println ("String Literal value : " + const1 );
8
+
9
+ StringBuffer s_buffer = new StringBuffer ("Buffered Value" );
10
+ System .out .println ("String Buffer Class : " + s_buffer );
11
+
12
+ StringBuilder s_builder = new StringBuilder ("Builder Value" );
13
+ System .out .println ("String Buider Class's String : " + s_builder );
14
+
15
+ System .out .println ("Immutable String : " + const1 );
16
+ const1 = const1 .concat ("is now changed !" );
17
+ System .out .println ("Changed String value : " + const1 );
18
+
19
+ System .out .println ("\n Strings with and without new keyword : \n " );
20
+ System .out .println ("String without new Keyword : " );
21
+ System .out .println (const1 );
22
+ System .out .println ("\n String with new keyword : " );
23
+ System .out .println (s1 + " " + s_buffer + " " + s_builder );
24
+
25
+ byte asc1 [] = {65 ,67 ,75 };
26
+ System .out .print ("Array of Ascii : " );
27
+ for (int i = 0 ;i < asc1 .length ;i ++){
28
+ System .out .print (asc1 [i ] + " " );
29
+ }
30
+ String combined_str = new String (asc1 );
31
+ System .out .println ("\n String created using array of Array : " + combined_str );
32
+
33
+ char chr1 [] = {'A' ,'c' ,'k' };
34
+ System .out .print ("Array of Character : " );
35
+ for (int i = 0 ;i < chr1 .length ;i ++){
36
+ System .out .print (chr1 [i ] + " " );
37
+ }
38
+ String combined_st = new String (chr1 );
39
+ System .out .println ("\n Array of Character : " + combined_st );
40
+ }
41
+ }
0 commit comments