#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Java array method to find number repeated


    Hi, what is the syntax and method to use when trying to find the most repeated number and count the number of times is repeated in an array?

    int array[] = {2,3,3,4,4,4,4,6};

    //Method to find the most repeated #

    I can printed by using:

    system.out.println("4, is repeated 4 times");

    I would like to know the method to find the number 4.

    Thanks in advance!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    74
    Rep Power
    18
    Hi,

    there is no such method to calculate the mode of a list , and since this is classified as an homework assignment I assume that your teacher wants you to implement that yourself.
    If you have troubles with your implementation, we would be happy to help. We won't however provide a solution.
    In case that you have limited experience with programming, my advice to you would be to first create some pseudocode or simulate this problem with pen and paper. Then, you can translate that to a java solution

    Comments on this post

    • NormR agrees

IMN logo majestic logo threadwatch logo seochat tools logo