Hey, so I need some major help with this problem.. maybe not major, but I'm trying to generate random 100 numbers, from 0 to 9, in an array using Math.random, but it only outputs 0s which is very confusing to me. Also, I need to be able to count how many different integers there are like 0s, 1s, 2s... 8s, 9s. Also confused on how to do that exactly, thought I had it, but now I just confused my whole brain. Please help. Here's my code, I only got as far as the array then got stumped on the counting part. Thank you in advance!
and my resultsimport java.util.Arrays; public class countDigits { public static void main(String[] args) { //Create random generator and values int numbers = (int)(Math.random() * 10); int arrayCount = 1; final int numOfArrays = 100; int[] digitArray = new int[numOfArrays]; int counts = 0; //Create array for (arrayCount = 1; arrayCount <= digitArray.length; arrayCount++) { System.out.print(digitArray[numbers] + " | "); } //Count different integers } }
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0