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  ww.  ja v a2  s. c om

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

Related Example