2

I want to print a char '=' repeatedly where I give the no. of times the asterisk should be repeated.

Example: count = 20 and I want to print ==================== using printf() and format specifiers.

1 Answers1

4

String#repeat

Simply append a string generated by String#repeat method, in Java 11+.

String result = "=".repeat( 20 ) ;

====================

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154