title: Check for more than one element in an array
body: <p>By mode, I am checking if the array has duplicates. I checked similar queries down here but they addressed the question with answers containing <code>ArrayList</code> and <code>HashMap</code>. I am not familiar with them and trying to answer it with an array. My following code only works for 1 duplicate and unable to perform multiple duplicate detection.</p>
  
  <pre><code>public class Mode {
  
      public static void main(String[] args) {
          int[] num = {2,3,4,5,8,8,8,7,7,7};
          int mode = mode(num);
          System.out.println(mode);
      }
  
      public static int mode(int[] num){
          for(int x=0; x &lt; num.length; x++){
              for(int y=x+1; y &lt; num.length; y++){
                  if(num[x] == num[y]){
                      return num[x]; 
                  }
              }
          }
          return num[0]; 
      }
  }
  </code></pre>