java - How do I convert an object from an ArrayList() or ArrayList<String> to ArrayList<Integer>? -


so, in code, read in .txt file single, unspecified arraylist, not converting int or integer when try parse out. text file looks this:
name 1
number 1
number 2
number 3
name 2
etc.
trying make number 1 increment when name 1 selected list.
students initial arraylist (tried both arraylist , arraylist())
kb scanner
players arraylist
totalgames arraylist tries rewrite students(k+1)

system.out.println(students.get(k));   if(kb.nextint()!=0)   {   players.add(k);   totalgames.add((integer)students.get(k+1));   }   

but comes incompatible types error. there way make error go away without changing arraylists?

arraylist students=new arraylist();         int num=0;         while (qbrdr.hasnext()&&num<loop)         {             students.add(qbrdr.nextline());             students.add(new integer(qbrdr.nextint()));             students.add(new double(qbrdr.nextdouble()));             students.add(new double(qbrdr.nextdouble()));             num+=4;         }   

during initialization, needed record them int or double not object or string.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -