string.copyValueOf()
String.copyValueOf() copy chars from an array of chars to create a string
Syntax
String1.copyValueOf(String2, int offset, int count)
offset (optional ) : starting point of copying chars
count (optional ) : Number of chars from starting point to be copied.
offset and count both are to be given ( not one ).
The output is string
Here are some examples with output.
char[] my_str1= {'p','l','u','s','2','n','e','t'};
String my_str2="";
my_str2=my_str2.copyValueOf(my_str1,0,4);
System.out.println(my_str2); // plus
my_str2=my_str2.copyValueOf(my_str1,2,4);
System.out.println(my_str2); // us2n
my_str2=my_str2.copyValueOf(my_str1,5,3);
System.out.println(my_str2); // net
my_str2=my_str2.copyValueOf(my_str1);
System.out.println(my_str2); // plus2net
« All String functions
« Java
This article is written by plus2net.com team.
plus2net.com