You can use a HashMap where the key contains the X and Y position. If you don't want to implement a new class for the key to your Map you could just use a String of the form "X_Y" where X is the index into the first dimension and Y is the index into the second.
Map<String, YourClass> map = new HashMap<>();
To put an item at position 2345, 6789, you would do this:
map.put(2345 + "_" + 6789, yourObject);
And to get it back:
YourClass yourObject = map.get(2345 + "_" + 6789);
Why choose this method over using some kind of Tuple? I think the short answer is that Java doesn't come with a Tuple or Pair class. You could write your own and add your own hashCode() and equals() implementation or you could use something like Map.Entry<K, V>
. Whether you choose a String for your key or a class for your key will make no significant difference to execution time. You loose some type safety by using a String and you make up for that with some brevity of code.