Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to repeat string in java

public class Main 
{
  public static void main(String[] args) 
  {
    String str = "Abc";
 
    String repeated = new String(new char[3]).replace("", str);
 
    System.out.println(repeated);
  }
}
Comment

Repeat a string in java

string.repeat(count);
Comment

how to repeat string in java

FOR JAVA 8 :

import static java.util.stream.Collectors.joining;
import static java.util.stream.Stream.generate;

String repeat(int count) {
 
    return Stream.generate(() -> "ABC").limit(count).collect(Collectors.joining());
}
Comment

PREVIOUS NEXT
Code Example
Java :: android adb is using too much cpu 
Java :: Java try Keyword 
Java :: android system navigation back bar hide 
Java :: open cv for java 
Java :: syntax for new module creation in java 
Java :: java.lang.NullPointerException: Cannot store to double array because is null 
Java :: how to accept only numbers and whitespace in java 
Java :: how to hide search from menu android studio from activity 
Java :: java stream list order lambda 
Java :: Calculator repeat 
Java :: string to integer online 
Java :: sysout is not working in eclipse 
Java :: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 
Java :: Algorithms - filtering 
Java :: how to switch between two stylesheets in javafx. 
Java :: output of java file in terminal 
Java :: computeifabsent hashmap java 
Java :: how to set up basic java workspace 
Java :: Jax-RS path annotation 
Java :: skip list java 
Java :: while(++i<5)f*=i;System.out.println(f); 
Java :: java join if string is empty delimiter not used 
Java :: Magic square java user input 
Java :: implement hashmap 
Java :: tipe data c++ 
Java :: The JCheckBox and JComboBox classes belong to which package? 
Java :: bipredicate in java 
Java :: before first in jdbc 
Java :: Calling the Pre-Defined Method in Java 
Java :: springboot getting body value 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =