title: 2D Array containing Arrays
body: <p>I'm working on a discrete math problem in Java where I'm trying to find r-permutations up to n with repetition. This means if r = 4, n = 2 we can have:<br>
  1 1 1 1<br>
  1 1 1 2<br>
  1 1 2 1<br>
  1 1 2 2, etc.<br>
  Repetition means 1112 is a unique combination, however 1211 is not because 1112 already contains 3 1's and 1 2.<br>
  Therefore I wrote code to iterate through all the permutations, and every iteration is stored in an array. There is a "Master Array" which I planned on being a 2D Array where the first dimension are all unique arrays or permutations. Therefore all I have to do is create a temp array of the new iteration and use Arrays.sort and compare the temp array to all the indexes in the master array (this works because 1211, 1112, 2111, and 1121 all sort to 1112 in ascending order).<br>
  Now, the problem I'm having is storing these arrays into the 2D array Masterkey.<br>
  I've tried:<br>
  Masterkey[count] = array;, but when I print(Masterkey[count][0]) only a single integer is being output rather than the array. (array is the newest permutation)<br>
  Masterkey[count] = Arrays.copyOf(array, array.length);, once again prints a single integer rather than the array.<br>
  Masterkey[count] = array.clone();, also prints out just an integer.<br>
  I may be overlooking something simple, but I'm just struggling to get array to be stored in Masterkey.</p>