Friday, 14 August 2020

Scala: Concatenate strings

 Using ‘+’ operator, you can concatenate two or more strings.

Example

var str1 = "Hello"

var str2 = "World"

var str3 = str1 + " " + str2

scala> var str1 = "Hello"
var str1: String = Hello

scala> 

scala> var str2 = "World"
var str2: String = World

scala> 

scala> var str3 = str1 + " " + str2
var str3: String = Hello World

scala> print(str3)
Hello World



Previous                                                    Next                                                    Home

No comments:

Post a Comment