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




stripTrailing() FUNCTION


stripTrailing() Function


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


Example :



fun main() {

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


Output :



 HelloWorld

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


var x = " Hello "

java_Collections

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


var y = x.stripTrailing()

java_Collections

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