This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Extracting values from an ArrayList? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Extracting values from an ArrayList?" Watch "Extracting values from an ArrayList?" New topic
Author

Extracting values from an ArrayList?

D diller
Greenhorn

Joined: Nov 15, 2007
Posts: 29
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

Joined: Nov 15, 2007
Posts: 29
Upon reviewing it all, I think I may need to use a Hashmap...
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
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.


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
D diller
Greenhorn

Joined: Nov 15, 2007
Posts: 29
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extracting values from an ArrayList?
 
Similar Threads
stuck in a loop
Regarding Collections
HashMap
Integer.MIN_VALUE
Getting value of all the indices of all objects from an arraylist