• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I get the value as int for integers store in ArrayList?  RSS feed

 
Ted Schrey
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I stored five ints in an ArrayList (variable name scores). When I try to get the values, eg: int score = scores.get(1); it says incompatible types, Object can not be converted to integer. Is there a way to get the integer value out? I want ArrayList so I could use the Collections.sort() on it.
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please post your code so that people will be able to tell what needs to be modified.
From this much information it looks like you are using raw type ArrayList which is very much discouraged.
 
Ted Schrey
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tapas, but I just figured it out.... I forgot to set my List to ArrayList<Integer> Sorry about that!
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bingo
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!