title: LinkedList : Collections.max() throwing NoSuchElementException
body: <p>I am not iterating the <code>LinkedList</code> by any means like scanner or other methods, I am using <code>Collections.max()</code> to get maximum number from the <code>LinkedList</code>.</p>
  
  <p>I have read on Stack Overflow that this exception is thrown due to iterator or scanner or tokenizer, but I am using none of them.</p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  
  class TLG {
      public static void main(String[] args)throws IOException {
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  
          LinkedList&lt;Integer&gt; first = new LinkedList&lt;Integer&gt;();
          LinkedList&lt;Integer&gt; second = new LinkedList&lt;Integer&gt;();
  
          int cases = Integer.parseInt(br.readLine());
  
          for(int i=1;i&lt;=cases;i++) {
              String score = br.readLine();
              int number1 = Integer.parseInt(score.split(" ")[0]); 
              int number2 = Integer.parseInt(score.split(" ")[1]); 
              int diff = number1 - number2;
  
              if(diff &gt; 0){
                  first.add(diff);    
              }
              else {
                  second.add(java.lang.Math.abs(diff));    
              }
          }
  
          Integer max1 = Collections.max(first);  // Getting Exception here
          Integer max2 = Collections.max(second); // Getting Exception here
  
          if(max1 &gt; max2) {
              System.out.println(1+" "+max1);
          }
          else {
              System.out.println(2+" "+max2);
          }
      }
  }
  </code></pre>