title: Java subtract two ints, result should be a minimum of zero
body: <p>I want to subtract one integer from another, and the result should floor at 0. So 2 minus 4 should equal 0. I could just do</p>
  
  <pre><code>int result = x - y;
  if (result &lt; 0) result = 0;
  </code></pre>
  
  <p>But is there a more elegant way?</p>