code: public static String makeRandomString(int length, int maxVal) {
      if (length < 0) {
        return null;
      }
  
      length = Math.min(length, 1025);
  
      if (maxVal < 0) {
        return null;
      }
  
      maxVal = Math.min(maxVal, 35);
  
      StringBuffer res = new StringBuffer();
      Random rand = new Random();
  
      for (int i = 0; i <= length; i++) {
        res.append(randChars[rand.nextInt(maxVal + 1)]);
      }
  
      return res.toString();
    }
docs: Creates a string of given length where each character comes from a
  set of values 0-9 followed by A-Z.
  
  @param length    returned string will be this long. Less than 1k + 1
  @param maxVal    maximum ordinal value of characters.  If < than 0,
  return null.  If > 35, 35 is used instead.
  @return String   the random string