 <p>Here's my go at it... basically an unrolled loop. The JIT would probably have recognized that a loop would have gone from 0 to 3 and unrolled it itself anyway, but who knows...</p> <pre><code>public static int max(int[] a) { int max = a[0] &gt; a[1] ? a[0] : a[1]; max = a[2] &gt; max ? a[2] : max; return a[3] &gt; max ? a[3] : max; } </code></pre> <p>Sum would obviously just be <code>a[0] + a[1] + a[2] + a[3]</code>.</p> <hr> <p>You could also try packing the four 0-255 values in an int, and do some bit-operations instead.</p>