从文件中读取元素,并将其作为对象存储在ArrayList中

|| 我有一个文件包含(字符串,整数,浮点数,字符) 12 1.8 一种 约翰 23.5 我想读取它们并将它们存储在ArrayList中。我的ArrayList类型是object。但是,当我运行它时,仍然会出现异常。
    public static void main(String [] args) throws IOException{


    try{
            FileReader a=new FileReader(\"src/SET_A.txt\");
            Scanner b=new Scanner(a);
            ArrayList<Object> c=new ArrayList<Object>();
            while(b.hasNextLine())
                {
                    Object d=b.nextInt();
                    c.add(d);
                 }
            System.out.println(\"The content of arraylist is: \" + a);
    }
    catch(Exception exception)
    {
        exception.printStackTrace();
    }
    }
    
已邀请:
您正在显示文件还是ArrayList的内容?您应该显示C而不是A。如果不是,请告诉我们什么是例外。     

要回复问题请先登录注册