Java - Write code to get Repeating String using StringBuilder

Requirements

Write code to get Repeating String

Use StringBuilder class

Hint

Use for loop to build the string

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        int count = 42;
        char character = 'a';
        System.out.println(getRepeatingString(count, character));
    }/*from   ww w. j av a  2s  . com*/

    public static String getRepeatingString(int count, char character) {
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < count; i++) {
            result.append(character);
        }
        return result.toString();
    }
}

Related Exercise