title: How to get the index and max value of an array in one shot?
body: <p>Given a list of integer elements, how to get the max value and it's index in one shot. If there is more than one element with same max value, returning index of any one of them is fine.</p>
  
  <p>For example:</p>
  
  <pre><code>// Initialize list of integer
  List&lt;Integer&gt; intList = Arrays.asList(5, 8, 3, 2);
  // To get max value
  Optional&lt;Integer&gt; maxVal = intList.stream().reduce(Integer::max);
  // But how could I also get its index without iterating the array again?
  </code></pre>
  
  <p>If I have to do it only once, I could just sort the array and get the first or last one (based on sort order). However, I would like to see how we can do it without sorting.</p>