String Constructor In Java Example
Chapter:
String Handling
Last Updated:
06-07-2016 11:15:08 UTC
Program:
/* ............... START ............... */
public class StringConstructor {
public static void main(String args[]) {
char c[] = { 'J', 'a', 'v', 'a' };
String s1 = new String(c);
String s2 = new String(s1);
System.out.println(s1);
System.out.println(s2);
}
}
/* ............... END ............... */
Output
Notes:
-
The String class supports several constructors. To create an empty String,
- you call the default constructor. For example : String s = new String();
Tags
String Constructor, Java