3:50 pm - Sunday February 19, 8728

String Program using copyValueOf(char[] data, int offset, int count) method

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

// StringĀ  Program using copyValueOf(char[] data, int offset, int count) method */

class copyValue{
public static void main(String[] args){
char[] ch1=new char[] {'H','e','l','l','o'};
String s=String.copyValueOf(ch1, 2, 3);
/* copyValueOf(char[] data, int offset, int count) method returns String with the contents of a character array.
char[] data- character array which holds some data
offset -The first character in the char[] to be written to the String. This value is represents the index position.
count - length of character to be written to the String
*/
System.out.println("The String(s) contains : "+s);
}
}

Output:
E:\String>javac copyValue.java

E:\String>java copyValue
The String(s) contains : llo
*/

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply