Working with Text
7 min · Kotlin
Join strings, measure them, and use Kotlin string templates.
Enemy 1 of 5
This code joins two strings with + to make one greeting and prints it. Press Run to see the joined text.
Why this works
Text in Kotlin is stored as a String value, written between double quotes. You can join two strings together with the + operator, the same way you'd combine numbers with addition. Kotlin overloads + so it means concatenation (joining) when both sides are strings.
This works even when mixing a String with other types in some cases (like a String plus a number), because Kotlin will convert the other value to text automatically. Still, using + repeatedly to build up a sentence from many pieces gets clunky fast, which is exactly the problem the next section's string templates solve.
Rena
Your AI tutor. She walks you through each step.
Asking for help is part of coding. Rena reads your code and gives you a hint. She is free with an account: 20 hints a day.