About 9,510,000 results
Open links in new tab
  1. java - Simple way to repeat a string - Stack Overflow

    Here is the shortest version (Java 1.5+ required): 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. …

  2. String Class repeat () Method in Java with Examples

    Jan 28, 2021 · The string can be repeated N number of times, and we can generate a new string that has repetitions. repeat () method is used to return String whose value is the concatenation …

  3. Repeat String N times in Java [8 ways] - Java2Blog

    Sep 27, 2022 · We can repeat String N times using a for loop in java. This is an iterative way to solve this problem. There are some points to note: We take the input string str and a variable …

  4. How to Repeat a String in Java - Delft Stack

    Mar 11, 2025 · This article explores various simple approaches to repeating a string in Java. Discover how to use loops, StringBuilder, and the String.repeat () method for efficient string …

  5. String repeat () - Repeat string N times in Java - HowToDoInJava

    Oct 1, 2022 · Learn to repeat a given string N times, to produce a new string which contains all the repetitions, though a simple Java program. We will use method Sting.repeat (N) (since …

  6. Java’s String.repeat() Method Explained - Medium

    Nov 24, 2024 · This method creates a new string by repeating the original string a specified number of times. It is particularly useful for generating patterns, padding strings, or creating …

  7. How to repeat String N times in Java - Studytonight

    Jan 22, 2021 · In this post, we are going to repeat a string N time using Java code. While working with string there can be a need of repeating a string, for that purpose, Java provides repeat() …

  8. Java String repeat() Method

    Aug 1, 2019 · Java String repeat () is a simple utility method that can be used to concatenate a string specific number of times. It may produce OutOfMemoryError if the resulting string length …

  9. Java String repeat () Method

    The String.repeat() method in Java is used to repeat a string a specified number of times. This guide will cover the method's usage, explain how it works, and provide examples to …

  10. How to Repeat a String N Times in Java | LabEx

    Learn three ways to repeat a string N times in Java, including the Java 11 repeat () method, the String Constructor, and the replace () method.

  11. Some results have been removed
Refresh