Java - Write code to create Spaces by repeating ' ' using for loop

Requirements

Write code to create Spaces by repeating ' ' using for loop

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        int howMany = 42;
        System.out.println(createSpaces(howMany));
    }/*from w  w w .j  ava 2s .c  om*/

    public static String createSpaces(int howMany) {
        String result = "";
        for (int n = 0; n < howMany; n++) {
            result += " ";
        }
        return result;
    }
}

Related Example