以前に何度も尋ねられたことは知っていますが、それでも自分の間違いを理解できません..
これは、配列内の繰り返し回数をカウントするために私が書いている通常のコードです(:)これを行うには非常に長い方法になる可能性があります。考えられる場合は、より小さな方法も提案してください)
public int find(int[] sequence)
{
    Arrays.sort(sequence);
    int temp=0,count=0,j=0;
    HashMap<Integer,Integer> data = new HashMap<Integer,Integer>();
        for(int i:sequence){
        Integer c = new Integer(count);
        Integer d = new Integer(j);
        if(i!=temp) {
        if(count!=0) data.put(c,d);
        count++;
        j=1;
        temp=i;
        }
        else j++;
        }
        count++;//This one causes the error
        //System.out.println(count);
        Integer c = new Integer(count);
        Integer d = new Integer(j);
        data.put(c,d);
            long ans =  TheSwapsDivTwo.factorial(sequence.length);
        for(int i=1;i<=data.size();i++){
                ans /=  TheSwapsDivTwo.factorial(data.get(i).intValue());
                System.out.println(data.get(i));
                }
                return (int)ans;
}
public static long factorial(int n) {
            long fact = 1; // this  will be the result
            for (long i = 1; i <= n; i++) {
                fact *= i;
            }
            return fact;
}       
メソッドはループ内putでエラーを生成しませんが、forループ外の実装ではエラーを生成します。
エラーは次のようになります。
java.lang.NullPointerException
at TheSwapsDivTwo.find(TheSwapsDivTwo.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.topcoder.services.tester.java.TestProcess$Runner.run(TestProcess.java:386)
PS count++ が原因でエラーが発生しました...本当に愚かです..ループが範囲外になりました..