ADocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
String in Kotlin represents an immutable sequence of UTF-16 characters. On the JVM, Kotlin’s String class is mapped directly to java.lang.String. Because strings are strictly immutable, any operation that appears to modify a string (such as concatenation or replacement) allocates and returns a new String instance rather than mutating the original object in memory.
Kotlin provides two primary types of string literals: escaped strings and raw strings.
Escaped Strings
Enclosed in double quotes ("), escaped strings support standard C-style character escaping mechanisms (e.g., \n, \t, \", \\).
"""), raw strings do not support character escaping. They can span multiple lines and contain arbitrary text, including unescaped double quotes. They are typically paired with standard library functions like trimIndent() or trimMargin() to strip leading whitespace for code readability.
$ character.
- Simple variable references use a bare
$. - Complex expressions or property accesses require curly braces
${}.
String implements the CharSequence interface. Individual characters can be accessed in constant time via the indexing operator [], which internally invokes the get(index: Int) function.
String is a sequence of Char elements, it supports direct iteration via standard loops or higher-order functions.
- Structural Equality (
==): Evaluates whether the character sequences of two strings are identical. It safely handles nulls and compiles down tojava.lang.String.equals()on the JVM. - Referential Equality (
===): Evaluates whether two references point to the exact same object in memory. Due to JVM string pooling, identical string literals often share the same reference.
Master Kotlin with Deep Grasping Methodology!Learn More





