Finding difference between consecutive numbers in an array
<p>I need following output
Ex:</p>

<p><code>int array [] = {1, 2, 3, 4, 5};</code></p>

<p>Should be done using for loop</p>

<p>Output should be in form:</p>

<pre><code>List      Difference
 1            0
 2            1
 3            1
 4            1
 5            1
</code></pre>

<p>Here's the code I'm using, it works fine till 4 but then at 5 it says outofbounds because its looking at position 5 in array which does not exits. So, I need help!!!</p>

<p>Code:</p>

<pre><code>for (int counter = 0; counter &lt; degreedays.length;++counter){
    System.out.println("\t" + degreedays[counter] + "\t\t\t" + (degreedays[counter+1] - degreedays[counter]));
</code></pre>
