method works only in main class but not when called from its other class
<p>Hi i wrote a method to calculate the number of times a number appears in an array .The problem is it works when written in the same class as the main program but does not work when its written in a different class.</p>

<pre><code>public class Digits {


    public static void main(String[] args) {
        int []b={1,1,1,1,2};

    int c=  Digits.numberCount(b,5);
    System.out.println(c);
    }




      public static int numberCount(int[]numbers,int number){
    int count=0;
    for(int i=0;i&lt;numbers.length;i++){
        if(number==numbers[i])
            count++;
    }
    return count;
          }

}
</code></pre>

<p>it works in the above instance  but when not when i try to use the method from another class but in the same project</p>

<pre><code>public class DigitsA {
    private int[]numbersrange;


    public DigitsA(){
        numbersrange=new int[9];

    }

    public static int numberCount(int[]numbers,int number){
        int count=0;
        for(int i=0;i&lt;numbers.length;i++){
            if(number==numbers[i])
                count++;
        }
        return count;
    }

}
</code></pre>
