Java String repeat() method
Java String repeat() method
String repeat() method added jdk 11.
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.
Java Program Example:
class StringRepeat{
public static void main(String args[]){
String str = "Two";
System.out.println(str.repeat(2));
}
}
output:
Two Two
Comments
Post a Comment