repeat string in java
public class Main
{
public static void main(String[] args)
{
String str = "Abc";
String repeated = new String(new char[3]).replace("\0", str);
System.out.println(repeated);
}
}
repeat string in java
public class Main
{
public static void main(String[] args)
{
String str = "Abc";
String repeated = new String(new char[3]).replace("\0", str);
System.out.println(repeated);
}
}
How to repeat strings in java
//For above Java 11
public class Test
{
public static void main(String[] args)
{
String s1 = "Hello Guys!"
int timesToRepeat = 5;
//Sturcture: *String*.repeat(int times)
String repeatString = s1.repeat(timesToRepeat);
System.out.println(repeatString);
}
//Will Come out as
//Hello Guys! Hello Guys! Hello Guys! Hello Guys! Hello Guys!
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us