Friday 13 June 2014

String (StringBuffer buffer)

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

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment