Scala String trim() method with example
Last Updated :
29 Oct, 2019
The trim() method is utilized to omit the leading and trailing spaces in the stated string.
Method Definition: String trim()
Return Type: It returns the stated string after removing all the white spaces.
Example: 1#
object GfG
{
def main(args : Array[String])
{
val result = " Nidhi Singh " .trim()
println(result)
}
}
|
Example: 2#
object GfG
{
def main(args : Array[String])
{
val result = " Nidhi Singh GfG " .trim()
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...