Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




repeat() FUNCTION


To repeat a String a few number of times, Kotlin provides us with a Function called 'Repeat()' that repeats a string a few number of times.


Let us see the below example.


Example :



fun main() {   
   	
    var x = "Hello"
    var y = x.repeat(3)
            
    println(y)
}


Output :



 HelloHelloHello

So, if you see the output. The statement,


var y = x.repeat(3)

Repeats the String 'Hello' three times.


y = strings.Repeat(x,3)

java_Collections