How to repeat a string n times in Scala

1 Answer

0 votes
object RepeatString {
  def main(args: Array[String]): Unit = {
    var s = "abc"
    val n = 3
  
    val repeated = s * n
    
    println(repeated) 
  }
}

 
 
/*
run:
   
abcabcabc
 
*/

 



answered Dec 23, 2024 by avibootz

Related questions

1 answer 78 views
1 answer 111 views
1 answer 98 views
98 views asked Dec 23, 2024 by avibootz
1 answer 119 views
119 views asked Dec 23, 2024 by avibootz
1 answer 74 views
74 views asked Dec 23, 2024 by avibootz
...