C ++ program to concatenate a string given number of times | Java program to concatenate given string n number of times ; Function which return string by concatenating it . ; Copying given string to temporary string . ; Concatenating strings ; Driver code
class GFG { static String repeat ( String s , int n ) { String s1 = s ; for ( int i = 1 ; i < n ; i ++ ) s += s1 ; return s ; } public static void main ( String [ ] args ) { String s = " geeks " ; int n = 3 ; System . out . println ( repeat ( s , n ) ) ; } }