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
I guess you are trying to say that the class Claseqla has 2 attributes. If so, then you can create a Claseqla object and set the value of one of the attributes with s.nextline()
while(s.hasNextLine())
{
Claseqla cq = new Claseqla();
cq.setCareer(s.nextLine());
clista.add(cq);
}
This is asumming that you have an attribute named career (String) in your Claseqla class with its respective setter function.
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
.