Java - Write code to create Line by repeating - using for loop

Requirements

Write code to create Line by repeating - using for loop

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        int howLong = 42;
        System.out.println(createLine(howLong));
    }/*from   w  w  w.jav  a 2  s. c o m*/

    public static String createLine(int howLong) {
        String result = "";
        for (int n = 0; n < howLong; n++) {
            result += "-";
        }
        return result;
    }
}

Related Example