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));
    }/*  ww w  .  j av a2 s  .co m*/

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

Related Example