请参阅此程序代码:
public class RemoveTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.print(remove(new int[] {1, 2, 3, 4}));
}
static int [] remove(int[] a){
int[] b = new int[a.length - 1];
System.arraycopy(a, 1, b, 0, a.length - 1);
return b;
}
}
但是给出了垃圾输出。我在Eclipse IDE上尝试它
答案 0 :(得分:2)
您已经看到了Object
's toString()
method的结果;数组也是对象。
System.out.print(Arrays.toString(remove(new int[] {1, 2, 3, 4})));