Start learning free

LESSON 66 OF 677 · STRINGS I

Uppercase and Lowercase in Kotlin

Lesson

In Kotlin, String objects have built-in methods to change their case:

s.uppercase()   // converts all characters to uppercase
s.lowercase()   // converts all characters to lowercase

Here are some examples:

val word = "Hello World"
val upper = word.uppercase()  // "HELLO WORLD"
val lower = word.lowercase()  // "hello world"

val name = "ALICE"
println(name.lowercase())  // "alice"

These methods return a new String — the original is not modified.


Assignment
Follow the Coding Tutorial and convert word to both uppercase and lowercase!


Hint
Use word.uppercase() and word.lowercase().

STEP 1 OF 2
    Ctrl + Enter to check