public
String(StringBuffer buffer)
Allocates
a new string that contains the sequence of characters currently
contained in the string buffer argument.
class StringConstructor12{ public static void main(String args[]){ StringBuffer s1 = new StringBuffer("Hello"); String s2 = new String(s1); System.out.println("s1 = " + s1); System.out.println("s2 = " + s2); } }
Output
s1 = Hello s2 = Hello
No comments:
Post a Comment