title: Difference between OptionalInt and int?
body: <pre><code>OptionalInt max = IntStream.of(arr).max();
  </code></pre>
  <p>Or</p>
  <pre><code>int maximum = 0;
  for (int i : arr) {
       maximum = Math.max(i, maximum);
  }
  </code></pre>
  <p>Both these methods return maximum value. What does <code>OptionalInt</code> make a difference? As per the definition of <code>OptionalInt</code>, if value is present it returns <code>getAsInt()</code> but if value is not present, it throws an <code>Exception</code>.</p>