Implement an algorithm to shuffle an array of numbers
<p>I wrote codes for the following question but they don't work. I get random numbers but the shuffle method don't shuffle them. Would you please help me?</p>

<pre><code>for( each index i)

   choose a random index j where j&gt;=i.
   swap the elements at index i and j.
</code></pre>

<p>My code is:</p>

<pre><code>public static void shuffle(int[] a){
   for( int i = 0; i &lt; a.length-1; i++){
       int range = a.length; 
       int j = (int) (Math.random() * range);
       swap(a, i, j);      
  }
}

public static void swap(int[] array, int i, int j){

        if (i != j) {
            int temp = array[i];
            array[i] = array[j];
            array[j] = temp;
        }
    }
</code></pre>
