Suppose I have to enter 10 numbers. Now how can I count the occurrence of each number in my input? using array.
For example, if I enter 3 4 2 3 3 4 5 7 9 9. The output will be sth like
3 : 3times
4 : 2times
I have an array to store 10numbers. Then another array to count the occurrence. But I don't know how to make it work
I only self-study java for 3weeks, so please help.
Use a Map<Integer, Integer> where the key is one of your numbers and the associated value is the number of times that number occurred in the sequence.
Originally Posted by sinobu