I have this class:
public class MyClass{
private static Map<int[], Terrain> allTerrain = new HashMap<int[], Terrain>();
public static void main(String[] args){
populate();
int[] test = {0, 0};
System.out.println(allTerrain.get(test));
}
private static void populate() {
for (int i=0; i<10; i++) {
int[] index = {i, i};
allTerrain.put(index, new Terrain());
}
int[] test = {0, 0};
System.out.println(allTerrain.get(test));
}
}
Inside the method the allTerrain.get()
method returns the instance of the object, but when I use allTerrain.get()
outside of the method, it returns null
for all the entries.
Everything runs on the main thread so concurrency is not a problem (I think).
Any ideas on how to fix this?