Strings are represented by the type {{String}}. Strings are immutable. Elements of a string are [characters|Basic types#Characters] can be accessed by the indexing operation: {{s\[i\]}}. A string can be iterated over with a *for* loop:
{jet}
for (c in str) {
  println(c)
}
{jet}

h3. String literals

[Kotlin] has two types of string literals: _escaped_ strings that may have escaped characters in them and _raw_ strings that can contain newlines and arbitrary text. An escaped string is very much like a *Java* string:
{jet}
val s = "Hello, world!\n"
{jet}
Escaping is done in the conventional way, with a backslash.

A _raw_ string is delimited by a triple quote ({{"""}}), contains no escaping and can contain newlines and any other characters:
{jet}
val text = """
  for (c in "foo")
    print(c)
"""
{jet}

{anchor:Templates}

h3. Templates

Strings may contain _template expressions_, i.e. pieces of code that are evaluated and whose results are concatenated into the string. A template expression starts with a dollar sign ({{$}}) and consists of either a simple name:
{jet}
val i = 10
val s = "i = $i" // evaluates to "i = 10"
{jet}
or an arbitrary expression in curly braces:
{jet}
val s = "abc"
val str = "$s.length is ${s.length}" // evaluates to "abc.length is 3"
{jet}

h3. What's next

* [Expressions]