A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 一步步 中级黑马   /  2013-11-14 10:10  /  1249 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 一步步 于 2013-11-14 10:42 编辑

public static Set<Student>getStudent()throws IOException
        {
                BufferedReader bufr=new BufferedReader(new InputStreamReader(System.in));
                String line=null;
                Set<Student>stus=new TreeSet<Student>();
                while((line=bufr.readLine())!=null)
                {
                        if("over".equals(line))
                                break;
                        String[] info=line.split(",");
                        Student stu=new Student(info[0]),Integer.parseInt(info[1]),Integer.parseInt(info[2]),Integer.parseInt(info[3]));
                        stus.add(stu);
                }
                bufr.close();
                return stus;
               

这段代码中Student stu=new Student(info[0]),Integer.parseInt(info[1]),Integer.parseInt(info[2]),Integer.parseInt(info[3]));这行语句提示:
Multiple markers at this line        - Integer cannot be resolved or is not          a field        - Syntax error on token ",", . expected        - Syntax error on token ",", ; expected        - Syntax error on token ",", . expected        - Syntax error on token ")", delete this          token        - The constructor Student(String) is          undefined这样的错误是怎么回事啊?

3 个回复

倒序浏览
你仔细看一下代码——info[0]后面多了一个“)”。你这一用")"关上了,当然就相当于一个参数的构造方法了,当然提示你——The constructor Student(String) is          undefined 这个构造方法没有定义了

so easy....自从来了黑马论坛,妈妈再也不用担心我的学习了
回复 使用道具 举报
要看你的构造函数怎么写的,构造函数的参数不匹配
回复 使用道具 举报
spiderman 发表于 2013-11-14 10:32
你仔细看一下代码——info[0]后面多了一个“)”。你这一用")"关上了,当然就相当于一个参数的构造方法了, ...

我怎么决的你怎么这么牛呢,:lol
多谢啦
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马