object Scala_String {
def main(args: Array[String]): Unit = {
{
val str = " Scala Exercises ";
// Trim the whitespace from the front and back of the String.
val new_str = str.trim();
// Display the strings for comparison.
println("Original String:-" + str);
println("New String:-" + new_str);
}
}
}
Sample Output:
Original String:- Scala Exercises
New String:-Scala Exercises
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer