Do Math.max and Math.min change the value they are applied to?
<p>I've been reading some code that one of my lecturers set and he has written something like "Let us set a maximum and minimum for a value."</p>

<p>Then he writes (and I'm paraphrasing values here)</p>

<pre><code>int x = 5;
x = Math.min(x, 0);
x = Math.max(x, 10);
</code></pre>

<p>Then he carries on with his code as if x is still equal to 5 whereas when I run this code through my computer the max and min functions always change the value of x to 0 and then 10. </p>

<p><strong>Does this sound like a mistake on his part? Should he have reverted x before carrying on? Or does this function work in some other way depending on circumstances that it does actually set a maximum and minimum value without changing the original variable?</strong></p>
