Java String copyValueOf(data, offset, count)
方法将返回一个String
,表示指定数组中的字符序列。
语法
以下是此方法的语法 -
public static String copyValueOf(char[] data, int offset, int count)
参数
data
- 字符数组。offset
- 子数组的初始偏移量。count
- 子数组的长度。
返回值
- 此方法返回包含字符数组字符的
String
值。
示例
public class Test {
public static void main(String args[]) {
char[] Str1 = { 'y', 'i', 'i', 'b', 'a', 'i', '.', 'c', 'o', 'm', 'd' };
String Str2 = "";
Str2 = Str2.copyValueOf(Str1, 2, 6);
System.out.println("Returned String: " + Str2);
}
}
执行上面示例代码,得到以下结果:
Returned String: ibai.c
上一篇:
java中方法重载和方法重写的区别
下一篇:无