Problem Statement
How do you work with strings in Kotlin including templates, multi-line strings, and common operations?
Explanation
Kotlin strings support templates with dollar sign for variables and dollar curly braces for expressions like val message equals Hello dollar name your age is dollar curly braces age plus 1 curly braces making string building more readable than concatenation. Use triple quotes for multi-line strings preserving formatting and line breaks useful for SQL queries or JSON templates, with trimIndent or trimMargin to clean up indentation. Strings in Kotlin are immutable like Java and have rich APIs including substring, split, replace, trim, startsWith, endsWith, contains, and more. You can also use raw strings for regular expressions without escaping backslashes, convert strings to numbers with toInt or toIntOrNull for safe conversion, and use string comparison with equals or double equals checking value equality not reference. Extension functions let you add custom string operations easily, and Kotlin's string handling is more convenient than Java while maintaining compatibility.
