Q:

Counting 100 Random Numbers

I am trying to generate 100 random numbers between 0 and 9, and display the count for each  number
Is this solution correct? I want to improve, what could I have done better?
java.util.Scanner k = new Scanner(System.in);

int[] numbers = new int[100];

for (int i = 0;i<numbers.length;i++)
{
    numbers[i] = (int) (Math.random() * 10);
}

int [] counts = new int[10];

for (int i = 0;i<numbers.length;i++)
{
    counts[numbers[i]%numbers.length]++;
}

for (int i=0;i<counts.length;i++)
{
    if (counts[i]>1)
        System.out.println(i+1+" Generates: "+(counts[i])+" times");
    else
        System.out.println(i+1+" Generated: "+(counts[i])+" time");
}

A:

I think you have overthought this, you only need one array - of 10 values (for the range 0 - 9 there are ten unique values), generate one hundred values in that range, and increment the value in the array (that is your count of numbers), then loop to display. Something like,
int[] numbers = new int[10];
for (int i = 0; i < 100; i++) {
    int ndx = (int) (Math.random() * numbers.length);
    numbers[ndx]++;
}
for (int i = 0; i < numbers.length; i++) {
    System.out.printf("%d was generated %d times.%n", i, numbers[i]);
}

And in Java 8+ you might write the above with IntStream and lambda(s) like
int[] numbers = new int[10];
IntStream.range(0, 100).forEach( //
        x -> numbers[(int) (Math.random() * numbers.length)]++);
IntStream.range(0, numbers.length) //
        .forEachOrdered(x -> System.out.printf( //
                "%d was generated %d times.%n", x, numbers[x]));

