• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Extracting values from an ArrayList?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic