0Pricing
Scala for Backend Engineering & Functional Programming · Lesson

Common String Methods

Split, trim, and transform text.

Useful String Methods

Scala strings come with many built-in methods for searching, changing case, and trimming.

Remember that strings are immutable, so each method returns a new string rather than changing the original.

val s = "Scala"
println(s.length)
println(s.toUpperCase)

Changing Case

Use toUpperCase and toLowerCase to convert the case of every letter.

These are handy for case-insensitive comparisons or normalizing input.

val name = "Backend"
println(name.toUpperCase)
println(name.toLowerCase)

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