• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Extracting values from an ArrayList?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my situation so far:

I have created an ArrayList which users add values to; a String and an integer for each element in the ArrayList. I am using the .get(x) method with a user-inputted variable (x) to select a specific element ID. Fantastic. Now I'd like to get just the integer value (say, for example, a variable the user inputs earlier which is named z) that was input into the ArrayList for that particular set of values. Can this be done?
 
D diller
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Upon reviewing it all, I think I may need to use a Hashmap...
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by D diller:
Upon reviewing it all, I think I may need to use a Hashmap...



Yes, sounds like you want a Map.
List.indexOf(Object) sounds useful (but not ideal) for your use.
 
D diller
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, I just redid the entire program using a HashMap instead and I've gotten further in 7 hours of programming than I did in about four times that much because once I wasn't scared of HashMaps, it was a lot easier to use them
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!