repeat string for certain times using StringBuffer - Android java.lang

Android examples for java.lang:String Algorithm

Description

repeat string for certain times using StringBuffer

Demo Code

import android.text.Html;
import android.text.Spanned;

public class Main{

    public static String repeat(String string, int repeat) {
        StringBuffer str = new StringBuffer();
        for (int i = 0; i < repeat; i++)
            str.append(string);//from   w w w. ja  v a2 s  . com
        return str.toString();
    }

}

Related Tutorials