title: How to find the smallest and the biggest number of items in array in Java?
body: <p>I was wondering if there is any method to display the highest and the smallest number of items stored in array/linkedlist. </p>
  
  <pre><code>public Checkout()
  {
  
     tillQueue = new LinkedList&lt;String&gt;(); 
     currentLen = 0;      
     lengthList = new ArrayList &lt;Integer&gt;();
  
     mean = 0; 
     r = new Random();
  }
  
  
  public void simulation()
  {
      System.out.println("Time" + "\t" + "Rnd" + "\t" + "Queue Status");
      for (int t=2; t&lt;10; t++) //number of time-steps in the simulation.
      {
          rndNumber = r.nextInt(6) +1; // generates random number between 1 and 6.          
  
          if (rndNumber==4 || rndNumber==2 || rndNumber==6) 
          {            
               // if rndNumber is 4, t is added to a queue.
                  tillQueue.add(String.valueOf(t));
                  currentLen++;
  
          }
          else if ((rndNumber==1 || rndNumber==3) &amp;&amp; !tillQueue.isEmpty())
          {                              
              tillQueue.remove();
              currentLen--;
             //if rndNumber is either 1 or 3, person is removed from the queue
          }
  </code></pre>
  
  <p>and that's the outcome:</p>
  
  <blockquote>
    <p>    Queue number 1 </p>
    
    <p><p>Queue
    <p>[2]
    <p>[2, 3]
    <p>[2, 3, 4]
    <p>[3, 4]
    <p>[3, 4]
    <p>[4]
    <p>Queue is empty
    <p>Queue is empty
    <p>Mean length of queue 1= 1.375
    <p>Max length of queue 1= 0.0
    <p>Min length of queue 1= 0.0</p>
  </blockquote>
  
  <p>As you can see from the output the highest number of people is 3 (2,3,4) and lowest 0 (empty)
  How can I calculate those values?</p>