This question seems to be very basic, but I don’t know why, there is something wrong and I can’t figure it out.
int [] concept = null;
int i = 0;
for (Iterator iterator = conceptsListGeneral.iterator(); iterator.hasNext();) {
Map<String, Object> map = (Map<String, Object>) iterator.next();
String count = (String)map.get("count");
// concept[i] = new Integer(count).intValue();
// concept[i]= Integer.parseInt(count, 10);
Integer intObj2 = Integer.valueOf(count);
concept[i]= intObj2.intValue();
i++;
}
The comented lines are some of the thigs I have tried. I get a java.lang.NullPointerException on the last line.
By debugging, I know String count has a value, and olso Integer intObj2.
DOes anybody know why?? Thanks in advance
It’s just because your
conceptarray is null. Replace your first line withand you’ll have it working.
EDIT
Oh, and like Edwin says, don’t forget to assign
ia value.