0

I have the below code:

 import java.util.HashMap;
    import java.util.Map;

    public class Pangram1 {

        public static void main(String[] args)
        {
        Character [] ch = new Character[] {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
        HashMap<Character,Integer> map1 = new HashMap<Character,Integer>();
        String s = "The quick brown fox jumps over the lazy dog";
        int count = 0;
        int greater = 0;
        for (char character: ch)
        {
            map1.put(character, count);
        }

        for(Map.Entry<Character,Integer> entry : map1.entrySet() )
        {
            System.out.println("key is" + "\t" + entry.getKey() + "\t" + "Value is" + entry.getValue());
        }

        for(int i = 0; i < s.length();i++)
        {   
            Integer count1 = map1.get(s.charAt(i));
Line 28 --->            count1.intValue();
            map1.put(s.charAt(i),new Integer (count1)); 

            if(count1 > greater)
            {
                greater = count1;
            }
        }

        if(map1.values().contains(1) && greater == 1)
        System.out.println("Pangram");
        else if(map1.values().contains(0))
        System.out.println("Not Pangram");
        else if(greater > 1)
        System.out.println("Multiple Pangram" + "\t" + greater);

    }
    }

I am getting this error Exception in thread "main" java.lang.NullPointerException at Pangram1.main(Pangram1.java:28)

I have tried all ways such that there wouldn't be autoboxing/Unboxing problems but still exception throws up.

Could someone please help me with it ?

Thanks !!

sri
  • 21
  • 1

0 Answers0