@Test public void generateString() { String result = RandomUtil.generateString(2); Assert.assertEquals(2, result.length()); result = RandomUtil.generateString(20); Assert.assertEquals(20, result.length()); result = RandomUtil.generateString(8); Assert.assertEquals(8, result.length()); }
public static String generateString(int length) { char[] buf = new char[length]; for (int i = 0; i < buf.length; i++) { buf[i] = chars.charAt(random.nextInt(chars.length())); } return new String(buf); }
RandomUtil { public static String generateString(int length) { char[] buf = new char[length]; for (int i = 0; i < buf.length; i++) { buf[i] = chars.charAt(random.nextInt(chars.length())); } return new String(buf); } }
RandomUtil { public static String generateString(int length) { char[] buf = new char[length]; for (int i = 0; i < buf.length; i++) { buf[i] = chars.charAt(random.nextInt(chars.length())); } return new String(buf); }  }
RandomUtil { public static String generateString(int length) { char[] buf = new char[length]; for (int i = 0; i < buf.length; i++) { buf[i] = chars.charAt(random.nextInt(chars.length())); } return new String(buf); }  static String generateString(int length); }
RandomUtil { public static String generateString(int length) { char[] buf = new char[length]; for (int i = 0; i < buf.length; i++) { buf[i] = chars.charAt(random.nextInt(chars.length())); } return new String(buf); }  static String generateString(int length);  }