Q:
Scala program to concatenate strings using the plus (+) operator
belongs to collection: Scala String Programs
Scala String Programs
- How to determine if a string contains a regular expression in Scala?
- Scala program to split string
- Scala program to convert string to integer
- How to count the number of characters in a string in Scala?
- How to create a range of characters in Scala?
- How to left-trim and right-trim strings in Scala?
- How to get date, month and year as string or number in Scala?
- How to replace a regular expression pattern in a string in Scala?
- Extracting difference, intersection, and distinct characters between two strings in Scala
- How to convert a string to byte array in Scala?
- How to convert byte array to string in Scala?
- How to convert a string to date in Scala?
- How to convert hex string to int in Scala?
- How to convert hex string to long in Scala?
- How to convert Int to Double in Scala?
- Scala program to compare strings using equal to (==) operator
- Scala program to compare strings using equals() method
- Scala program to compare strings using compareTo() method
- Scala program to compare strings using equalsIgnoreCase() method
- Scala program to concatenate strings using the plus (+) operator
- Scala program to concatenate strings using the concat() method
- Scala program to extract the substring from a string
- Scala program to find the length of the string
- Scala program to get characters from the string
- Scala program to check the string starts with a specified substring
- Scala program to check the string ends with specified substring
- Scala program to get bytes array from string using getBytes() method
- Scala program to copy the content of string into a character array
- Scala program to copy the content of string into a character array
- Scala program to convert the string into a character array
- Scala program to convert an integer number into a string
- Scala program to convert a floating-point number into a string
- Scala program to get the hash code of the string
- Scala program to get the index of the first occurrence of the specified substring
- Scala program to get the index of the last occurrence of the specified substring
- Scala program to replace the character with another character in the string
- Scala program to demonstrate the replaceAll() method
- Scala program to demonstrate the replaceFirst() method
- Scala program to split the string based on the given separator
- Scala program to demonstrate the subSequence() method
- Scala program to convert the string into lowercase
- Scala program to convert the string into uppercase
- Scala program to trim a string
- Scala program to concatenate string using \'s\' method of string interpolation
- Scala program to concatenate formatted string using \'f\' method of string interpolation
- Scala program to print raw string using the raw method of string interpolation
- Scala program to create a string using StringBuilder class
- Scala program to append a character to an immutable string using the \'+=\' operator
- Scala program to append a string to an immutable string using the \'++=\' operator
- Scala program to append a number to an immutable string using append() method
- Scala program to clear the content of StringBuilder string
- Scala program to delete a substring from StringBuilder string
- Scala program to insert a substring into StringBuilder string
- Scala program to replace a substring into StringBuilder string
- Scala program to get the length of StringBuilder string
- Scala program to get characters from StringBuilder string
- Scala program to check whether a string is empty or not
- Scala program to check nullable string
- Scala program to create a string using StringBuffer class
- Scala program to demonstrate the append() method with StringBuffer class
- Scala program to delete a substring from a string created using StringBuffer
- Scala program to insert a substring into string created using StringBuffer
Program/Source Code:
The source code to concatenate strings using the plus (+) operator is given below. The given program is compiled and executed on the ubuntu 18.04 operating system successfully.
Output:
In the above program, we used an object-oriented approach to create the program. And, we created an object Sample. Here, we defined main() function. The main() function is the entry point for the program.
In the main() function, we created three string variables str1, str2, str3 that are initialized with "Hello ", "World ", "" respectively. Then we concatenated strings str1, str2 using the plus (+) operator and assigned the result into str3. After that, we printed concatenated string on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer