title: Largest 5 in array of 10 numbers without sorting
body: <p>Here's my code to find the max number in an array of numbers, but i can't seem to understand how to get the top 5 numbers and store them in an array and later retrieve them</p>
  
  <p>Here's the code:</p>
  
  <pre><code>public class Max {
  
  
      public static void main (String[] args) 
      {
          int i;
          int large[]=new int[5];     
          int array[] = {33,55,13,46,87,42,10,34,43,56};
          int max = array[0]; // Assume array[0] to be the max for time-being
  
          //Looping n-1 times, O(n)
          for(  i = 1; i &lt; array.length; i++) // Iterate through the First Index and compare with max
          {
              // O(1)
              if( max &lt; array[i])
              {
                  // O(1)
                  max = array[i];// Change max if condition is True
                  large[i] = max;
              }
          }
          for (int j = 0; j&lt;5; j++)
          {
              System.out.println("Largest 5 : "+large[j]);
          }
          System.out.println("Largest is: "+ max);
          // Time complexity being: O(n) * [O(1) + O(1)] = O(n)
      }
  
  }
  </code></pre>
  
  <p>I'm using an array to store 5 numbers, but when i run it, it is not what i want.
  Can anyone help me with the program?</p>