0PricingLogin
Scala for Backend Engineering & Functional Programming · Lesson

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)

All lessons in this course

  1. String Basics
  2. s, f and raw Interpolators
  3. Common String Methods
  4. Multiline Strings
← Back to Scala for Backend Engineering & Functional Programming