Just a very small question… I seem to run into too much complexity here: I have to realize an index-structure like {42, someString}. I tried:
Object entry[][] = new Object[1][1];
ArrayList<Object> my_list = new ArrayList<Object>();
However that looks really strange. Isn’t there a better much simpler solution to just store some Integer and a String? I need to perfrom search for the Strings and return the Integer… so I thought Collections and ArrayLists are good friends in the Java API.
Solution: use a Map
Uhm, do you perhaps need a Map?
You can search it using
Reference: Sun Java Tutorial > Collection Trail > Interfaces > The Map Interface
Fixing the OP’s Code
BTW, the code in the question is flawed. Here’s how you would do it if you wanted to use a List of object arrays (which you shouldn’t):
Now you could search like this:
However, this is just for reference, don’t do it this way. The Collections Framework contains solutions for almost all standard cases. Use a Map.