Java String Repeat repeat(String pattern, int count)

Here you can find the source of repeat(String pattern, int count)

Description

repeat

License

Apache License

Declaration

public static String repeat(String pattern, int count) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Iterator;

public class Main {
    public static String repeat(String pattern, int count) {
        final StringBuilder builder = new StringBuilder();
        for (int i = 0; i < count; i++) {
            builder.append(pattern);/*from w  w w  . jav  a2  s  . com*/
        }
        return builder.toString();
    }

    public static String toString(Object object) {
        if (object == null) {
            return "null";
        }
        return object.toString();
    }

    public static String toString(Iterable<?> it, String separator) {
        final StringBuilder builder = new StringBuilder();
        final Iterator<?> iterator = it.iterator();
        while (iterator.hasNext()) {
            builder.append(iterator.next().toString());
            if (iterator.hasNext()) {
                builder.append(separator);
            }
        }
        return builder.toString();
    }
}

Related

  1. createRepeatedString(char c, int length)
  2. deleteRepeatStr(String repeatStr, String separator)
  3. repeat(String in, int count)
  4. repeat(String item, int count)
  5. repeat(String s, int cnt)
  6. repeat(String s, int times)
  7. repeat(String s, int times)
  8. repeat(String s, int times)