
String and String Buffer • 267
5. String(char[]value, int offset, int length)
This form of constructor allocates a new
String
so that it represents the sequence of characters
currently contained in the character array argument. It can be used in the following way:
char ch[]={'T','w','o','p','i','e'};
String s = new String(ch,3,3);
System.out.println(s); //prints pie
6. String(String original)
This form of constructor initializes a newly created String object so that it represents the same
sequence of characters as the argument. In other words, the newly created string is a copy of the
argument String. It can be ...