java.lang.String.copyValueOf(char[] data, int offset, int count)%uA0方法返回表示指定的数组中字符序列的字符串。
声明
以下是java.lang.String.copyValueOf()方法的声明
public static String copyValueOf(char[] data, int offset, int count)
参数
-
data%uA0-- 这是字符数组。
-
offset%uA0-- 这是最初的子数组的偏移量。
-
count%uA0-- 这是子数组的长度。
返回值
此方法返回表示指定的数组中字符序列的字符串。
异常
-
NA
例子
下面的例子显示java.lang.String.copyValueOf()方法的使用。
package com.yiibai import java.lang.* public class StringDemo { public static void main(String[] args) { // character array char[] charArr = { &aposC&apos, &aposO&apos, &aposM&apos, &aposP&apos, &aposI&apos, &aposL&apos, &aposE&apos, &apos &apos, &aposO&apos, &aposN&apos, &aposL&apos, &aposI&apos, &aposN&apos, &aposE&apos } /* returns a String that contains the characters of the character array with offset as 8 and length as 6 */ String str = String.copyValueOf(charArr, 8, 6 ) // prints the substring with length as 6 System.out.println(str) } }
让我们来编译和运行上面的程序,这将产生以下结果:
ONLINE