File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Finding mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Finding mode" Watch "Finding mode" New topic

Finding mode

Kwesi Prat

Joined: Dec 02, 2003
Posts: 7
I am trying to figure out some coding on how to find mode for an array of integers? How do I go about the coding for mode?
Thank you.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Welcome to JavaRanch!
If memory serves me right, the mode is the most common value, yes? Well, you loop over the array, and count the occurrences of each value.
Give it a try, come back and show us how far you get.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Finding mode
It's not a secret anymore!