mercredi 28 août 2019

"if" not working as expected trying to print out right condition [on hold]

I am trying to use the if-condition. For example if the argument equals the condition in the if-statement, it will print what's defined in the if-clause, otherwise it will print out what's defined in the else-clause.

It doesn't seemed to work properly it works one way or it doesn't work at all

for (String arg: args){
    if (arg.equals("-d")){
        System.out.println(String.join("", Collections.nCopies(numberCharacters, (args[1]))));     
    } else {
        System.out.println(String.join("", Collections.nCopies(numberCharacters, str)));
    }
}

Aucun commentaire:

Enregistrer un commentaire