100k views
17 votes
How do I repeat a word in Java for example:

Are you okay?

Yes

Are you really okay?

Yes

Are you really really okay?

Yes

Here I want to repeat the word really in every sentence.

User Nqsir
by
3.2k points

1 Answer

6 votes

Answer: repeated = new String(new char[n]). replace("\0", s); Where n is the number of times you want to repeat the string and s is the string to repeat.

Step-by-step explanation:

User Sijan Bhandari
by
3.6k points