我在下面的代码下面给了我这个输出

1,2,3,4,3,4,5,4,3,5,3,4,5,5,4,64,
[Ljava.lang.String;@3e25a5
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f
[I@19821f

input.txt文件包含1,2,3,4,3,4,5,4,3,5,3,4,5,5,4,64,

代码是这样的。很明显,拆分时有一个简单的错误,但我发现很难找到。
public static void main(String[] args) {
    // TODO Auto-generated method stub



    try{
        FileInputStream fstream = new FileInputStream("input.txt");
        DataInputStream  dat = new DataInputStream (fstream);
        BufferedReader in = new BufferedReader(new InputStreamReader(dat));
        String[] str ;

        int arr[] = new int [100];


        String line;

        while ((line = in.readLine()) != null)
            {

                System.out.println(line);
                str = line.split(",");
                System.out.println(str);

                for(int i = 0 ;i<str.length ; i++)
                {
                    arr[i]= Integer.parseInt(str[i]);
                    System.out.println(arr);
                }
            }

        fstream.close();

    }

    catch(IOException e)
    {
        System.out.print(e);
    }


}

最佳答案

改变这个

   System.out.println(arr);


   System.out.println(arr[i]);

在打印数组arr之前,而不是在打印数组的元素之前。

09-16 07:17