Write a Scala program to trim any leading or trailing whitespace from a given string
- برمجة سكالا
- 2021-09-23
- mhanasmh00489829403
الأجوبة
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
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة