Station的构造函数是(int,String,int)
ArrayList<Station> allStationNames = new ArrayList<Station>()
申明之后怎么样的添加方法才是对的?
allStationNames.add(1, "Central",1);各种add啊什么的我都试了 疯狂报错
Multiple ers at this line
- Syntax error on token ",", Expression expected after this 
 token
- Syntax error on token "allStationNames", delete this 
 token

解决方案 »

  1.   

    构造函数是白定义的吗?
    allStationNames.add(new Station(1, "Central", 1))
      

  2.   

    .add new Station(1,"central",'1');
      

  3.   

    这个方法我摸索的时候也试过了
    他也还是报错 是我哪里写错了吗
    Multiple ers at this line
    - Syntax error on token ")", { expected
    - Syntax error on token ".", @ expected after this 
     token
      

  4.   

    写成这样会有下面的报错 allStationNames.add(new Station(1, "Central", 1));Multiple ers at this line
    - Syntax error, insert ")" to complete MethodDeclaration
    - Syntax error, insert "SimpleName" to complete 
     QualifiedName
    - Syntax error on token ".", @ expected after this token
    - Syntax error, insert "Identifier (" to complete 
     MethodHeaderName
      

  5.   

    这个方法我摸索的时候也试过了
    他也还是报错 是我哪里写错了吗
    Multiple ers at this line
    - Syntax error on token ")", { expected
    - Syntax error on token ".", @ expected after this 
     token你的实体类没有构造方法,只有一个无参构造器,加上一个带三个参数的构造器就行了
      

  6.   

    这个方法我摸索的时候也试过了
    他也还是报错 是我哪里写错了吗
    Multiple ers at this line
    - Syntax error on token ")", { expected
    - Syntax error on token ".", @ expected after this 
     token你的实体类没有构造方法,只有一个无参构造器,加上一个带三个参数的构造器就行了没看到下面,你这个list添加实体应该没问题,是别处的问题,看报错信息,打断点调试一下就知道是哪里的问题了