public class Strength3 extends ConsoleProgram {

    private static String[] blank;
    private static String it;
    public void run(){

        blank = new String[5];


        for (int i=0; i<5;i++){
            blank[i] = "-";
            it+=blank[i];
        }
        println(it);
            }

}

why does it print 'null' first. all i want is just 5 hyphens...thanks

Because you declare but do not define "it" so it's initial value is null, and since you are doing "+=" with String types you are getting the String value of that null reference (i.e. "null") plus the String you are appending to it.

Solution: initialize "it" to the empty string: private static String it = "";

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.