class ClassMain {
public static void main(String[] args) {
Test t = new Test();
System.out.println(t.testString(10));
}
}class Test {
int[] num;
public String testString(int n) {
num = new int[n];
for(int i=0;i<n;i++) {
num[i] = i;

}
return new String(num,0,n);
}
}public String(int[] codePoints,
              int offset,
              int count)
这个String对象的构造方法到底怎么用的,谢谢

解决方案 »

  1.   

    String
    public String(int[] codePoints,
                  int offset,
                  int count)
    分配一个新的 String,它包含该 Unicode 代码点数组参数的一个子数组的字符。offset 参数是该子数组第一个代码点的索引,count 参数指定子数组的长度。将该子数组的内容转换为 char;后续对 int 数组的修改不会影响新创建的字符串。 参数:
    codePoints - 作为 Unicode 代码点的源的数组。
    offset - 初始偏移量。
    count - 长度。
      

  2.   

    codePoints - 作为 Unicode 代码点的源的数组。
    是不是指的就是一般的整形数组吗
    offset是不是就是你想要取出来做新String的子数组在codePoints中的索引
      

  3.   


    但num[]里边的值太小了吧小值好象是控制符的
      

  4.   

    难道打印出来的是Unicode码对应的字符啊