My favourite language at this point is python, but the recent work on java 6 has been getting me a bit interested in shifting focus. So far, I've been pretty happy with the language, except for one thing that's been driving me crazy today.
In python one can easily put together a list of different primitives or strings, such as this, which contains both integers and strings.
And from there do a simple match for values in each to find the rest of the values. Looking for a phone number of 5554855555 for example, which would also give the correct position in the list for the name and address associated with it.
I'm a bit lost as to how this could be done in java. There seems to be an overwhelming amount of collections, but none of them seem to match what I'm looking for here.
posted 9 years ago
One way would be to create a Map and encapsulate the values in a class definition. You could then use one of the fields of the class definition as the key, and the object as the value.