Friday 13 June 2014

String (String original)

public String(String original)
Initializes a newly created String object so that it represents the same sequence of characters as the argument.

class StringConstructor11{
 public static void main(String args[]){
  String s1 = new String("Hello");
  String s2 = new String(s1);
  
  System.out.println("s1 = " + s1);
  System.out.println("s2 = " + s2);
  System.out.println("s1==s2 : " + (s1==s2));
 }
}

Output
s1 = Hello
s2 = Hello
s1==s2 : false




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment