code: public static String repeat(String str, int repeat) {
      if (str == null) return null;
      if (repeat <= 0) return Empty;
      if (repeat == 1) return str;
      final int len = str.length();
      final long longSize = (long) len * (long) repeat;
      final int size = (int) longSize;
      if (size != longSize) { throw new ArrayIndexOutOfBoundsException(
          "Required array size too large: " + String.valueOf(longSize)); }
  
      final char[] array = new char[size];
      str.getChars(0, len, array, 0);
      int n;
      for (n = len; n < size - n; n <<= 1) {
        System.arraycopy(array, 0, array, n, n);
      }
      System.arraycopy(array, 0, array, n, size - n);
      return new String(array);
  
    }
docs: <p>
  Repeat a String {@code repeat} times to form a new String.
  </p>
  
  <pre>
  repeat(null, 2) = null
  repeat("", 0)   = ""
  repeat("", 2)   = ""
  repeat("a", 3)  = "aaa"
  repeat("ab", 2) = "abab"
  repeat("a", -2) = ""
  </pre>
  
  @param str the String to repeat, may be null
  @param repeat number of times to repeat str, negative treated as zero
  @return a new String consisting of the original String repeated, {@code null} if null String
  input
  @since 3.0