0

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.

khelwood
  • 55,782
  • 14
  • 81
  • 108
Devjejd
  • 7
  • 1

0 Answers0