@Test public void testRepeat() { assertEquals("foo,foo", Strings.repeat("foo", 2, ",")); assertEquals("ooo", Strings.repeat("o", 3, "")); assertEquals("o", Strings.repeat("o", -3, "")); assertEquals("", Strings.repeat("ouch", 0, "")); }
public static String repeat(String text, int times, String separator) { if (isEmpty(text) || times < 0) { return text; } if (times == 0) { return EMPTY; } StringBuilder builder = new StringBuilder(); for (int i = 0; i < times; i++) { builder.append(text); if (i + 1 < times) { builder.append(separator); } } return builder.toString(); }
Strings { public static String repeat(String text, int times, String separator) { if (isEmpty(text) || times < 0) { return text; } if (times == 0) { return EMPTY; } StringBuilder builder = new StringBuilder(); for (int i = 0; i < times; i++) { builder.append(text); if (i + 1 < times) { builder.append(separator); } } return builder.toString(); } }
Strings { public static String repeat(String text, int times, String separator) { if (isEmpty(text) || times < 0) { return text; } if (times == 0) { return EMPTY; } StringBuilder builder = new StringBuilder(); for (int i = 0; i < times; i++) { builder.append(text); if (i + 1 < times) { builder.append(separator); } } return builder.toString(); } private  Strings(); }
Strings { public static String repeat(String text, int times, String separator) { if (isEmpty(text) || times < 0) { return text; } if (times == 0) { return EMPTY; } StringBuilder builder = new StringBuilder(); for (int i = 0; i < times; i++) { builder.append(text); if (i + 1 < times) { builder.append(separator); } } return builder.toString(); } private  Strings(); static boolean isStringLiteralSeparator(char character); static boolean isEmpty(CharSequence sequence); static String uncapitalize(String word); static String capitalizeFully(String text, Character delimiter); static String replace(String text, String search,
            String replacement); static String removeSuffix(String text, String suffix); static List<String> split(String text, String delimiter); static boolean containsWhitespace(String text); static boolean containsOnlyWhitespace(String text); static boolean containsOnlyDigits(String text); static String repeat(String text, int times, String separator); static String substringAfter(String text, String delimiter); static boolean isListLiteralStart(char character); static boolean isListLiteralEnd(char character); static boolean isListLiteral(String value); }
Strings { public static String repeat(String text, int times, String separator) { if (isEmpty(text) || times < 0) { return text; } if (times == 0) { return EMPTY; } StringBuilder builder = new StringBuilder(); for (int i = 0; i < times; i++) { builder.append(text); if (i + 1 < times) { builder.append(separator); } } return builder.toString(); } private  Strings(); static boolean isStringLiteralSeparator(char character); static boolean isEmpty(CharSequence sequence); static String uncapitalize(String word); static String capitalizeFully(String text, Character delimiter); static String replace(String text, String search,
            String replacement); static String removeSuffix(String text, String suffix); static List<String> split(String text, String delimiter); static boolean containsWhitespace(String text); static boolean containsOnlyWhitespace(String text); static boolean containsOnlyDigits(String text); static String repeat(String text, int times, String separator); static String substringAfter(String text, String delimiter); static boolean isListLiteralStart(char character); static boolean isListLiteralEnd(char character); static boolean isListLiteral(String value); static final String EMPTY; static final String GAP; static final String LINE_SEPARATOR; static final String LINE_SEPARATOR_LF; static final String LINE_SEPARATOR_CRLF; static final String LINE_SEPARATOR_CR; static final String SLASH; static final String FILE_SEPARATOR; static final String DOT; static final String UNDERSCORE; static final String NOT_AVAILABLE; static final String URL_PROCOTOL_FILE; static final String THIS; static final String HASH; }