package StringInJava;
public class StringExample2 {
/**
* @param args
*/
public static void main(String[] args) {
// creating string object by string literal
String s1 = "Bhanu";
String s2 = "Bhanu Pratap";
String s3 = "Bhanu Pratap Singh";
// converting char array to string
char ch[] = { 'T', 'e', 's', 't' };
String s4 = new String(ch);
char ch1[] = { 'T', 'e', 's', 't' ,'1'};
String s5 = new String(ch1);
char ch2[] = { 'T', 'e', 's', 't','2' };
String s6 = new String(ch2);
char ch3[] = { 'T', 'e', 's', 't','3'};
String s7 = new String(ch3);
// creating java string object by new keyword
String s8 = new String("example");
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
System.out.println(s4);
System.out.println(s5);
System.out.println(s6);
System.out.println(s7);
System.out.println(s8);
}
}
public class StringExample2 {
/**
* @param args
*/
public static void main(String[] args) {
// creating string object by string literal
String s1 = "Bhanu";
String s2 = "Bhanu Pratap";
String s3 = "Bhanu Pratap Singh";
// converting char array to string
char ch[] = { 'T', 'e', 's', 't' };
String s4 = new String(ch);
char ch1[] = { 'T', 'e', 's', 't' ,'1'};
String s5 = new String(ch1);
char ch2[] = { 'T', 'e', 's', 't','2' };
String s6 = new String(ch2);
char ch3[] = { 'T', 'e', 's', 't','3'};
String s7 = new String(ch3);
// creating java string object by new keyword
String s8 = new String("example");
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
System.out.println(s4);
System.out.println(s5);
System.out.println(s6);
System.out.println(s7);
System.out.println(s8);
}
}
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteCore Java Training in Electronic city