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




stripLeading() FUNCTION


stripLeading() Function


The stripLeading() Function is used to remove any unwanted character from the left side of the String with Space by default.


Example :



fun main() {

    var x = "   Hello  "
    var y = x.stripLeading()
    println(y+"World")
}


Output :



 Hello World

In the above code, we have declared a String ' Hello ' with leading and trailing spaces.


x = " Hello "

java_Collections

Then we have used the 'stripLeading()' function to remove the unwanted spaces from left side only.


var y = x.stripLeading()

java_Collections

So, the unwanted spaces are stripped out from the left side of the String.