title: Find the mode (most frequent value in an array) using a simple for loop?
body: <p>How do I find the mode (most frequent value in an array) using a simple for loop? </p>
  
  <p>The code compiles with a wrong output.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>public static void mode(double [] arr)
  {
      double mode=arr[0];
  
      for(int i = 1; i&lt;arr.length; i++)
      {   
          if(mode==arr[i])
          {
              mode++;
          }
  
       }
  
  
      return mode;
  }
  </code></pre>