code: private static int uniquifyCountAndCopy(String[] in, String[] out) {
          int count = 0;
          outer: for (int i = 0; i < in.length; i++) {
              if (in[i] != null) {
                  for (int j = 0; j < i; j++)
                      if (in[i].equals(in[j]))
                          continue outer;
                  if (out != null)
                      out[count] = in[i];
                  count++;
              }
          }
          return count;
      }
docs: Count the number of non-null non-duplicate elements in an array, and copy
  those elements to an output array if provided.
  
  @param in the input array
  @param out an output array, or null to count rather than copying
  @return the number of non-null non-duplicate elements