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));
    }/* w ww  .  j a va  2  s .c  om*/

    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