title: Stream min() and max() method in Lambda Expression with Comparator , returns first and last element only does not return min/max element
body: <p>Stream <code>min()</code> and <code>max()</code> method in Lambda Expression with Comparator, returns first and the last element only, does not return min/max element.
  Can anyone explain the working of min() and <code>max()</code>.</p>
  
  <pre><code>public class Hello {
      public static void main(String[] args) {
  
          ArrayList&lt;Integer&gt; al = new ArrayList&lt;&gt;();
          al.add(0);
          al.add(5);
          al.add(10);
          al.add(15);
          al.add(20);
          al.add(25);
  
          System.out.println(al);
  
          Integer l = al.stream()
                              .min((a, b) -&gt; -a.compareTo(b))
                              .get();
          System.out.println(l);
  
          Integer l2 = al.stream()
                              .max((a, b) -&gt; -a.compareTo(b))
                              .get();
          System.out.println(l2);
      }
  }
  </code></pre>
  
  <p>Output: 25 and 0 respectively</p>