How to fill array with random numbers limited to 0-20 : <p>I am having trouble placing the random generator in the array, how can I get #20 random numbers from 0-9 in the array? Then you count the occurrences of those numbers.</p>

<p>import java.util.Random;</p>

<p>public class CountDigits {</p>

<pre><code>public static void main(String[] args) {



    Random digit = new Random(); 

    int Random[] = new int [20];

    int Digits[] = {0,1,2,3,4,5,6,7,8,9}; 

    int Count [] = new int [10]; 


    for ( int i = 0; i &lt; Digits.length; i++) {


        for( int j = 0; j &lt; Random.length; j++) {

            if ( Digits [i] == Random [j] ) 
                Count[i]++; 
        }

    }


    for ( int i = 0; i &lt; Count.length; i++) {

        if ( Count[i] == 1) 
            System.out.printf(" %d  occurs  1 time " , Digits[i] ); 

        else
            System.out.printf("%d occurs %d times" , Digits[i], Count[i]); 

    }
</code></pre>

<p>result so far::
0 occurs 20 times1 occurs 0 times2 occurs 0 times3 occurs 0 times4 occurs 0 times5 occurs 0 times6 occurs 0 times7 occurs 0 times8 occurs 0 times9 occurs 0 times</p>
