2015-04-24 89 views
-3

我收到一個列表從AWS DynamoDB低於特定使用掃描代碼:空指針異常 - 安卓

List<DBMarkers> markers= new ArrayList<DBMarkers>(); 

markers = mapper.scan(DBMarkers.class, scanExpression); 
Log.d("DynDBS::markers recvd :", String.valueOf(markers.size())); //This shows size as 2 

for(DBMarkers temp : markers) { 
    temp.getname(); //method in my class - get nullpointer here 
} 

有誰知道如何着手?

+0

更換

for(DBMarkers temp : markers) { temp.getname(); //method in my class - get nullpointer here } 

如果你空指針那裏...場溫度爲空在那裏。不要再看 – juanhl

+0

問題在於你的mapper.scan函數中得到了空結果。嘗試記錄「temp」變量本身。我想你會發現它輸出爲logcat。 – Knossos

回答

-1

與此

for(int i=0; i<markers.size(); i++) { 
DBMarkers temp = markers[i] 
temp.getname(); //method in my class - get nullpointer here 
}