method add in ArrayList is not applicable for the arguments (String)

前端 未结 2 1312
眼角桃花
眼角桃花 2021-01-26 06:58

I\'m trying to read a .txt file that contains several lines with the name of a professional carreer in each one of them. I\'ve created a Scanner but whenever I want to add what

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-26 07:45

    s.nextLine() returns a String. But your ArrayList has generic type Claseqla. You need to create a Claseqla object using the string you grab from the s.nextLine() call, and then add that object to your ArrayList.

提交回复
热议问题