Warning: Invalid argument supplied for foreach() in /home/customer/www/techndeck.com/public_html/wp-content/plugins/use-any-font/includes/functions/uaf_font_functions.php on line 469
Repeat string N times using String.repeat(N) API in Java 11 - Techndeck

Repeat string N times using String.repeat(N) API in Java 11

In this post, we will learn “How to repeat a string N number of times in Java 11?”. Java 11 introduced a new method called repeat(N) to do that.

Here, we are going to learn following things:

  1. What is repeat(N) method?
  2. How to use it?

How to Repeat String in Java 11?...!!! Click To Tweet

 

Let’s Begin,

1. What is repeat(N) method?

repeat(N) is a string method of String class.

This method returns a string whose value is the concatenation of this string repeated count times. If this string is empty or count is zero then the empty string is returned.

Syntax:

 

2. How to use it?

Let’s take an example where we are repeating a word ‘Techndeck’ 5 times.

 

Output:

 

How to Repeat String in Java 11?...!!! Click To Tweet

Do you like this Post? – then check my other helpful posts:

Other Useful References:

 

Related Posts:

[wcp-carousel id=”5342″]

Promotional Content:

[wp_rss_retriever url=”https://justanordinarywriter.com/feed” items=”3″ excerpt=”30″ read_more=”true” credits=”true” new_window=”true” thumbnail=”100″ cache=”12 hours” orderby=”random”]

Leave a Reply

Your email address will not be published.Required fields are marked *

Facebook Twitter Instagram YouTube