title: How to get maximum value in an ArrayList
body: <p>I want to know how to compare the all array list element in the array list? Eg I want to compare element which is the largest number. Like comparing 1st element and 2nd element, 2nd element compares to the 3rd element. How to do it?</p>
  
  <pre><code>List &lt;Product&gt; productList= new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>Can anyone give some example on how to compare with this variable?</p>
  
  <pre><code>productList.get(i).getPrice()
  </code></pre>
  
  <p>Thanks for help.</p>