How to create a string with a repeated character N times in Java

1 Answer

0 votes
public class Program {
    public static void main(String[] args) {
        String repeated = "*".repeat(10); // Repeats '*' 10 times
        
        System.out.println(repeated); 
    }
}



/*
run:

**********

*/

 



answered Jul 28 by avibootz
...