I have this ArrayList – ArrayList<Object[]> tree…
I also have this Array – Object[] move…that has a size of 2.
In my program a unique 2D array is added to move[0] and an integer to move[1]. This array is then added to the ArrayList then the process is repeated so I have a list of ‘moves’.
My problem is I am unsure how to find the arrays (‘moves’) within the ArrayList (‘tree’) that contain a certain value in the move[1] element only – as the move[0] element will be unique everytime.
I then want to make an array/list of all of the matches. For example, an array that contains all of the move[0] values that match up to the move[1] value of 3. So I would be left with an array/list of 2D arrays that contain the required moves.
Thanks,
Matt
It seems to me that what you need is a
key-valuedata structure and you have chosen a rather odd way to implement it.You should use either a
HashTableif you can not use generics (you are in an old jdk for some reason) or use aHashMapusing types to enforce type safety.