Here you can find the source of multiply(final String string, final int times)
public static String multiply(final String string, final int times)
//package com.java2s; //License from project: Open Source License public class Main { public static String multiply(final char c, final int times) { if (times < 0) { throw new IllegalArgumentException(); }/*from ww w.ja va2 s .co m*/ if (times == 0) { return ""; } final StringBuilder builder = new StringBuilder(times); for (int i = 0; i < times; i++) { builder.append(c); } return builder.toString(); } public static String multiply(final String string, final int times) { if (times < 0) { throw new IllegalArgumentException(); } if (times == 0) { return ""; } final StringBuilder builder = new StringBuilder(string.length() * times); for (int i = 0; i < times; i++) { builder.append(string); } return builder.toString(); } }