Please help me understand this piece of code
<p>I have a java project done for school. This is a piece of code which i am having a hard time to understand its logic. Please shed some light on it.</p>

<pre><code>for(int i = 0; i&lt; leftbut.length; i++){
          int randomNumber =(int)(Math.random()*leftbut.length);
             tempNum = leftbut[randomNumber];
            leftbut[randomNumber] = leftbut[i];
            leftbut[i]=tempNum;      

     }
</code></pre>

<p>The leftbut in this case is actually an array of 9 buttons.
This code is supposed to shuffle the 9 buttons in different positions.
I just cant understand how this code works.</p>
