我被這個問題困住了,我不知道我的代碼有什麼問題,請幫助我。我得到這個代碼error java.lang.nullpointerexception
:錯誤:java.lang.nullpointerexception
List<DataPoint> listPoints;
if((listPoints = hashMap.get(h)) == null) {
listPoints = new ArrayList<DataPoint>();
DataPoint point = new DataPoint((int)songId, i);
listPoints.add(point);
hashMap.put(h, listPoints);
}
後logcat所以知道哪一行是'NPE'。 'hashMap'很可能是'null' – codeMagic
也許'hashMap'沒有初始化? – MrSmith42
你可以發佈其餘的代碼和什麼行實際上是拋出NullPointer? – draksia