How to repeat a string n times in Kotlin

1 Answer

0 votes
fun main() {
    var s: String = "abc"
    val n = 3
    
    val repeated: String = s.repeat(n)
    
    println(repeated)
}
 

 
/*
run:

abcabcabc
 
*/

 



answered Dec 23, 2024 by avibootz
...