code: public static int[] unique(int[] x) {
          HashSet<Integer> hash = new HashSet<>();
          for (int i = 0; i < x.length; i++) {
              hash.add(x[i]);
          }
  
          int[] y = new int[hash.size()];
  
          Iterator<Integer> keys = hash.iterator();
          for (int i = 0; i < y.length; i++) {
              y[i] = keys.next();
          }
  
          return y;
      }
docs: Find unique elements of vector.
  @param x an integer array.
  @return the same values as in x but with no repetitions.