class DotCom{
    int[] arr;
    int numOfhits=0;
    void setLocation(int[] location){
        int[] arr=location;
    } 
    String checkGuess(int guess){
        System.out.println(guess);
        String result="miss";
        for(int i:arr){
            if (i==guess){
                 result="hit";
                numOfhits++;
                break;
                }
            if(numOfhits==arr.length){
                result="kill";
            }
        }
        System.out.println(result);
        return result;
    }
}
class TestDotCom{
    public static void  main(String[] args){
        DotCom obj=new DotCom();
        int[] location ={1,2,3};
        obj.setLocation(location);
        int userGuess=2;
        String testResult="fail";
        String result=obj.checkGuess(userGuess);
        if(result=="hit"){
            testResult="passed";
            }
        System.out.println(testResult);
    }
}   
in Dotcom class the int[] arr=location causes error. When I remove that i doesn't get any error what is going on over here? The error I get are
2 Exception in thread "main" java.lang.NullPointerException
    at DotCom.checkGuess(DotCom.java:12)
    at TestDotCom.main(TestDotCom.java:8) 
I don't get it what's wrong with the program.
 
     
     
    