String Methods in Kotlin

Level 298 keystrokes

Shows common string operations: length, uppercase() and lowercase().

Kotlin code

// A string of 12 characters (the space counts too)
1val text = "Hello Kotlin"
// length returns the number of characters: 12
2println(text.length)
// uppercase() returns HELLO KOTLIN
3println(text.uppercase())
// lowercase() returns hello kotlin; text itself is unchanged
4println(text.lowercase())

Output

12
HELLO KOTLIN
hello kotlin
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Kotlin code and how often they appear.

  • (× 5
  • )× 5
  • .× 3
  • "× 2
  • =× 1

More Kotlin examples at level 2

← Kotlin typing practice