Friday, 13 June 2014

String (StringBuilder builder)

public String(StringBuilder builder)
Allocates a new string that contains the sequence of characters currently contained in the string builder argument.

class StringConstructor13{
 public static void main(String args[]){
  StringBuilder s1 = new StringBuilder("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