I have a class Box, and in Box there is an Map<Integer, ArrayList<String>> smallBoxArr = new HashMap<>();
If I want to store Strings in the smallBox, I use put(boxId, "store String");
Now in my Main Class, I want to get the length of a specific smallBox.
My code in Main:
Box box = new Box();
int boxId = 5;
System.out.println(box.smallBoxArr.get(boxId).size());
But I always get a NullPointerException.