我正在尝试将我的 int 数组的内容复制到 double 类型的数组中。我必须先施放它们吗?
我成功地将一个 int 类型的数组复制到另一个 int 类型的数组。但是现在我想编写将内容从数组复制A
到数组Y
(int 到 double)的代码。
这是我的代码:
public class CopyingArraysEtc {
public void copyArrayAtoB() {
double[] x = {10.1,33,21,9},y = null;
int[] a = {23,31,11,9}, b = new int[4], c;
System.arraycopy(a, 0, b, 0, a.length);
for (int i = 0; i < b.length; i++)
{
System.out.println(b[i]);
}
}
public static void main(String[] args) {
//copy contents of Array A to array B
new CopyingArraysEtc().copyArrayAtoB();
}
}