Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.HashMap.get(Object)" is null

Viewed 53

when I am trying to compare values of character(keys) using string in a Hashmap

for(int i = 0 ; i < s.length()-1 ; i++){

                if(map.get(s.charAt(i)) <= map.get(s.charAt(i+1))){
                    sum = sum+map.get(s.charAt(i));
                }
                else{
                    sum = sum + map.get(s.charAt(i+1)) - map.get(s.charAt(i));
                }
            }

can anybody help me out?

0 Answers
Related