Write a Scala program to concatenate a given string to the end of another string
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
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer