I don't understand what is happening here. Basically, my code looks something like this:
Double average = 0.;
for(Map<String, Double> map : model.getMaps()){
    average += map.get(key); // this line throws a NullPointerException
}
average /= model.getMaps().size();
If I then do:
Double average = 0.;
for(Map<String, Double> map : model.getMaps()){
    try{
        average += map.get(key); // this line throws a NullPointerException
    } catch(NullPointerException e){
        e.printStackTrace();
        System.out.println(map.get(key).toString());
    }
}
average /= model.getMaps().size();
It prints a number, not null. This is making me very confused.
More checks:
if(map==null) System.out.println("Map null");
else {
    if (map.get(key).toString() == null) {
         System.out.println(key + " null");
    } else {
        String newValS = map.get(key).toString(); //throws a NPE
    }
}
It is very weird that I checked for everything not being null and still it throws a NPE.
 
    