日期:2014-05-20  浏览次数:20654 次

求教一个输出的问题
为何下述代码总是输出:[I@129f3b5

public class test21 {
public static void main(String args[]) {
test21 t = new test21();
System.out.println(t.show("a"));
}

public int[] show(String str){
int[] a = new int[10];
for(int i=0; i<10; i++)
a[i] = 1;
return a;
}
}

------解决方案--------------------
a 是int[] 数组 不能直接输出
试试System.out.println(Arrays.toString(t.show("a")));
------解决方案--------------------
Java code
public static void main(String args[]) {
        test21 t = new test21();
        System.out.println(Arrays.toString(t.show("a")));
        }

        public int[] show(String str){
        int[] a = new int[10];
        for(int i=0; i<10; i++)
        a[i] = 1;
        return a;
        }

------解决方案--------------------
a 是int[] 数组 不能直接输出
试试System.out.println(Arrays.toString(t.show("a")));
------解决方案--------------------
探讨
为何下述代码总是输出:[I@129f3b5

public class test21 {
public static void main(String args[]) {
test21 t = new test21();
System.out.println(t.show("a"));
}

public int[] show(String str){
int[] a = new……