如何从 HashMap 打印 ArrayList?
Map<String, ArrayList<Car>> cars = new HashMap<String, ArrayList<Car>>;
ArrayList<Car> carList = cars.get("bmw");
for (int i = 0; i < carList.size(); i++) {
System.out.println(carList.get(i));
}
代码导致:
java.lang.NullPointerException
尽管“bmw”键存在并已填充。