Here you can find the source of pow(String str, int n)
Parameter | Description |
---|---|
str | the String to repeat. |
n | how often the string is repeated. |
public static String pow(String str, int n)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w. j av a2s .c o m * Power-function in the free Monoid over Characters (AKA "Strings"). * * @param str the String to repeat. * @param n how often the string is repeated. * @return tge resulting string. */ public static String pow(String str, int n) { StringBuilder b = new StringBuilder(); for (int i = 0; i < n; i++) { b.append(str); } return b.toString(); } }