Q:

Write a Scala program to concatenate a given string to the end of another string

0

Write a Scala program to concatenate a given string to the end of another string

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

object Scala_String {

  def main(args: Array[String]): Unit = {
    val str1 = "Scala Exercises and ";
    val str2 = "Python Exercises";
    println("Original strings:")
    println("String 1: " + str1);
    println("String 2: " + str2);

    // Concatenate the two strings together.
    val str3 = str1.concat(str2);
    // Display the new String.
    println("The concatenated string: " + str3);
  }
}

Sample Output:

Original strings:
String 1: Scala Exercises and 
String 2: Python Exercises
The concatenated string: Scala Exercises and Python Exercises

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now