人們,我需要你們對這個問題的幫助,因爲我找不到合適的解決方案來解決它。「線程中的異常」main「java.lang.NullPointerException」ArrayList
的問題是:
**Exception in thread "main" java.lang.NullPointerException
at edu.maimonides.www.progmul3.tps.tp1.Garage.park(Garage.java:57)
at edu.maimonides.www.progmul3.tps.tp1.GarageElPlus.main(Garage.java:29)
Java Result: 1**
//翻譯:汽車=汽車 - 摩托= Motorcicle - Camioneta =凡
**Class Park Slot**
public class Park Slot {
private ArrayList<Integer> bigParkSlot =
new ArrayList<>(Arrays.asList(1, 3, 5, 7, 9, 11));
private ArrayList<Integer> avaliableParkSlot =
new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22));
private Map<Integer, String> busyParkSlot = new HashMap<>();
private ArrayList uncoveredParkSlot =
new ArrayList<>(Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20));
private ArrayList coveredParkSlot =
new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
}
**Class Garage**
// Line 57
// the problem is here
ArrayList<Integer> pElem = c.getavaliableParkSlot();
int num = pElem.iterator().next();
我的猜測是,'C'是*空*當你調用'getavaliableParkSlot() '對此,它拋出錯誤 – Sujay
這是調試器的用途。在第57行放置一個斷點,然後在IDE中按下debug。看看'c'是什麼。否則,我們所說的一切都是*心理調試*,我們只是試圖猜測。 –