title: How to create 2d array with randomly generated, non-repeating numbers?
body: <p>I was trying to generate a simulation of Game of 15. Currently at the stage to print a 2D array of randomly generated numbers from 1-15. This could be an example of an output, where the empty space could be any spot in the array:</p>
  
  <pre><code>1   3   5   6
  7   9   10  13
  2   4   8   11
  12  14  15
  
  public class Game {
  public static void main(String[] args) {
      Set&lt;Integer&gt; set = new HashSet&lt;&gt;();
      int gameboard[][] = new int[4][4];
  
      while(set.size() != 4*4){
          set.add((int)(1+Math.random() * 16));
      }
  
      List&lt;Integer&gt; list = new ArrayList&lt;&gt;(set);
  
      for (int row=0; row &lt; gameboard.length; row++) {
          for (int col=0; col &lt; gameboard[row].length; col++) {
              gameboard[row][col] = list.get(row*gameboard.length + col);
              System.out.printf("%-4d",gameboard[row][col]);
          }
          System.out.println();
          }
        }
  </code></pre>
  
  <p>}</p>
  
  <p>However, my current code prints 1-15 in ascending order like this:</p>
  
  <pre><code>1   2   3   4
  5   6   7   8
  9   10  11  12
  13  14  15  16
  </code></pre>
  
  <p>How should I make the numbers scrambled and different for every run and as well as there being an empty element(like the output above) so the numbers range from 1-15?</p>