0
import java.util.Scanner;

    public class Mode{


        public static void main(String[] args){
            Scanner reader = new Scanner(System.in);

            int[] numList = new int[10];
            int array = 0;
            int mode = 0;

            for(int i = 0; i<10; i++){
                System.out.print("Enter a number: ");
                int data = reader.nextInt();
                numList[array] = data;
            }
        }
    }

I have been trying to find a way to have the code search for a certain number, but have failed at even that. I am a high school student learning java. I use the Fundamentals of Java textbook when working. Any help will be greatly appreciated, thank you.

Shivam Mohan
  • 397
  • 3
  • 14
gabe
  • 1
  • Now is a good time to read about `HashMap` in your textbook - it will be an ideal data structure for this problem. You could use it to store # of occurrences for each unique number. – sleepToken Feb 06 '20 at 18:06
  • 1
    Does this answer your question? [Write a mode method in Java to find the most frequently occurring element in an array](https://stackoverflow.com/questions/15725370/write-a-mode-method-in-java-to-find-the-most-frequently-occurring-element-in-an) – sleepToken Feb 06 '20 at 18:08
  • Or use a hashTable because it will be faster than a hashmap. (Ability to synchronize) – Jason V Feb 06 '20 at 18:36

0 Answers0