What's the output of this code written in java?
<pre><code>    int arr[ ] = new int[3];
for (int i = 0; i &lt; 3; i++) {
   arr[i] = i;
} 
int res = arr[0] + arr[2];
System.out.println(res);
</code></pre>

<p>I'm a beginner in java, as you can see, and I'm not quite sure what's the output of this. Can someone answer and explain along the way?</p>