String Basics
Create and combine strings.
What Is a String?
A String in Scala is a sequence of characters, like text you read or type.
You write a literal string by wrapping text in double quotes. Strings are one of the most common types you will work with in backend code.
val greeting = "Hello, Scala!"
println(greeting)Declaring String Values
Use val for a string that never changes, and var if you need to reassign it.
Scala infers the type String automatically, but you can also write it explicitly.
val name: String = "Ada"
var mood = "happy"
mood = "excited"
println(name)
println(mood)