0

I'm assigned to write a program which prints (x) amount of "*" in a row.

I tried using the "*".repeat(amount) command, but the software wont accept it as a solution. Also tried using for and while -loops, but I can't figure how to get the *'s be on the same row.

public class Tulostelua {

    public static void main(String[] args) {
        printStarts(3);
    }

    public static void printStart(int amount) {
    }
}


pakkis26
  • 53
  • 2

1 Answers1

0

You could either use print (which doesn't start a new line) or add the chars to a string and println that.

So if I understand your question correctly, you need something like this:

public void print(int amount) {
    for(int i = 0; i < amount; i++) {
        System.out.print('*');
    }
}
cegredev
  • 1,485
  • 2
  • 11
  • 25