# kotlin | JetBrains | Knowledge Base | Instagit

The Kotlin Programming Language. 

GitHub Stars: 52.3k

Repository: https://github.com/jetbrains/kotlin

---

## Articles

### [Kotlin Empty List: Why `emptyList()` Returns a Singleton and How It Differs from Other Initializations](/jetbrains/kotlin/kotlin-empty-list-function-speeches)

Discover why Kotlin emptyList() returns a singleton for efficiency. Learn how this immutable list differs from other initializations and saves memory.

- Tags: deep-dive
- Published: 2026-02-21

### [How to Break Out of a Kotlin forEach Loop: Complete Guide with Examples](/jetbrains/kotlin/kotlin-foreach-break-loop-question)

Learn how to break out of a Kotlin forEach loop using labeled returns or traditional for loops. Discover efficient ways to control loop execution in your Kotlin code.

- Tags: how-to-guide
- Published: 2026-02-21

### [How to Implement a RecyclerView in Android Kotlin with Item Click Handling](/jetbrains/kotlin/recyclerview-in-android-kotlin-basic-item-click-example)

Learn how to implement a RecyclerView in Android Kotlin with efficient item click handling. Find a clear example in the JetBrains/kotlin repository.

- Tags: tutorial
- Published: 2026-02-20

### [How to Use Kotlin sortedBy for Multi-Field Sorting with Mixed Ascending and Descending Order](/jetbrains/kotlin/kotlin-sortedby-multi-field-sort)

Learn to sort Kotlin collections by multiple fields using sortedWith and chained thenBy thenByDescending operators for mixed ascending descending order. Optimize your data.

- Tags: how-to-guide
- Published: 2026-02-20

### [How to Handle Kotlin Exceptions When a Method Throws: A Complete Guide to Result and runCatching](/jetbrains/kotlin/kotlin-exceptions-handle-method-throw)

Master Kotlin exceptions with runCatching. Learn to gracefully handle errors using Result and avoid nested try catch blocks for cleaner code.

- Tags: how-to-guide
- Published: 2026-02-20

### [Kotlin Internal vs Private: Visibility Modifiers Explained with Code Examples](/jetbrains/kotlin/kotlin-internal-vs-private-visibility)

Explore kotlin internal vs private visibility. Learn when to use private for file/class access and internal for module-wide exposure while keeping code private to your module.

- Tags: deep-dive
- Published: 2026-02-19

### [Java to Kotlin Converter: 10 Critical Pitfalls to Review for Correctness and Efficiency](/jetbrains/kotlin/java-to-kotlin-converter-pitfalls)

Automated Java to Kotlin conversion has pitfalls. Review nullability, mutability, exceptions, and visibility for correct, efficient, idiomatic Kotlin code.

- Tags: deep-dive
- Published: 2026-02-19

### [Kotlin String Concatenation: Efficient and Idiomatic Approaches for Modern JVM Development](/jetbrains/kotlin/kotlin-string-concatenation-efficient-idiomatic)

Discover the most efficient and idiomatic ways for Kotlin string concatenation. Learn about string templates, the + operator, and buildString for modern JVM development.

- Tags: deep-dive
- Published: 2026-02-18

### [Sealed Interface vs Sealed Class in Kotlin: Key Differences and When to Use Each](/jetbrains/kotlin/sealed-interface-kotlin-whats-the-difference)

Understand sealed interface vs sealed class in Kotlin. Discover their differences, statefulness, constructors, and when to use each for efficient restricted hierarchies. Learn Kotlin sealed interface.

- Tags: deep-dive
- Published: 2026-02-18

### [Val vs Var in Kotlin: Immutable and Mutable Properties Explained for Android Developers](/jetbrains/kotlin/difference-val-var-kotlin-android)

Master Kotlin val vs var for Android. Learn when to use immutable val or mutable var properties. Prefer val for safer, thread-safe code and boost your app development.

- Tags: deep-dive
- Published: 2026-02-16

### [Data Object Kotlin vs Regular Object: Key Differences and Usage Guide](/jetbrains/kotlin/kotlin-data-object-vs-regular-object)

Understand Kotlin data object vs regular object differences. Learn automatic method generation for data structures and improve your code.

- Tags: deep-dive
- Published: 2026-02-16

### [Handling Date and Time Formatting in Kotlin Time: A Complete Guide to Cross-Device Consistency](/jetbrains/kotlin/kotlin-time-date-locale-formatting)

Master Kotlin time formatting for cross-device consistency. Learn to store dates as ISO-8601 and format at the UI layer for identical behavior everywhere.

- Tags: how-to-guide
- Published: 2026-02-16

### [How to Use Kotlin String Templates for Complex Formatting with Multiple Variables and Expressions](/jetbrains/kotlin/how-to-use-kotlin-string-template-for-complex-strings)

Master Kotlin string templates to format complex strings with variables and expressions. Learn advanced techniques for cleaner, efficient code.

- Tags: how-to-guide
- Published: 2026-02-16

### [How to Use a Kotlin Lambda Expression: Syntax, Use Cases, and Compiler Internals](/jetbrains/kotlin/kotlin-lambda-when-how-use)

Master Kotlin lambda expressions with this guide. Learn syntax, practical use cases, and how the compiler handles them. Pass functions as values and simplify your code.

- Tags: deep-dive
- Published: 2026-02-16

### [Lombok @Data vs Java 14 Records: Key Differences for Data Classes](/jetbrains/kotlin/lombok-data-vs-java-14-records)

Compare Lombok @Data and Java 14 records. Understand key differences in mutability, accessors, and language features for creating efficient data classes.

- Tags: comparison
- Published: 2026-02-16

### [When to Use Sealed vs Internal in Kotlin: Controlling Class Visibility and Inheritance](/jetbrains/kotlin/kotlin-internal-vs-sealed-visibility-scenarios)

Learn when to use Kotlin sealed for closed hierarchies and exhaustive when expressions. Discover when to use internal to hide module details while allowing subclassing.

- Tags: deep-dive
- Published: 2026-02-16

### [Kotlin List to Map Conversion: 5 Efficient Methods for Custom Objects](/jetbrains/kotlin/efficient-kotlin-list-to-map-conversion)

Learn 5 efficient Kotlin list to map conversion methods for custom objects. Discover associate, associateBy, associateWith, and groupBy for O(n) performance and minimal allocations.

- Tags: how-to-guide
- Published: 2026-02-16

### [When Is the Kotlin Init Block Executed Relative to the Primary Constructor?](/jetbrains/kotlin/kotlin-init-when-executed)

Understand when Kotlin init blocks execute relative to primary constructors. Learn about the execution order of parameters, properties, and init blocks in Kotlin.

- Tags: internals
- Published: 2026-02-16

### [How to Declare and Use a Variable of an Enum Type in Kotlin: A Complete Guide](/jetbrains/kotlin/how-to-use-enum-kotlin-construct)

Learn to declare and use Kotlin enum variables. Define enum classes assign constants to variables and access properties or use them in when expressions for robust code.

- Tags: how-to-guide
- Published: 2026-02-16

### [Suspend Function Kotlin: Key Characteristics and Common Use Cases](/jetbrains/kotlin/what-is-a-suspend-function-kotlin)

Explore Kotlin suspend functions to build non-blocking asynchronous code. Learn their key characteristics and find common use cases for efficient concurrency.

- Tags: deep-dive
- Published: 2026-02-16

### [JSON to Kotlin Data Class Conversion: Efficient Strategies for Android Development](/jetbrains/kotlin/efficient-json-to-kotlin-data-class-conversion)

Streamline JSON to Kotlin data class conversion in Android with kotlinx-serialization. Generate type-safe, zero-reflection serializers efficiently using the @Serializable annotation for seamless integration.

- Tags: how-to-guide
- Published: 2026-02-16

### [What Is a Kotlin Inline Function and When to Use It: A Deep Dive into the Compiler](/jetbrains/kotlin/what-is-kotlin-inline-function-when-use)

Explore Kotlin inline functions and their compiler optimizations. Learn when to use them to eliminate overhead and enable advanced features like reified generics.

- Tags: deep-dive
- Published: 2026-02-15

### [How to Define Custom Conditions for a Kotlin When Expression: 3 Advanced Techniques](/jetbrains/kotlin/how-to-define-custom-conditions-kotlin-when)

Master Kotlin when expressions with custom conditions. Learn 3 advanced techniques including omitted-subject syntax, contains operator, and sealed class hierarchies for powerful logic.

- Tags: deep-dive
- Published: 2026-02-15

### [Is the Kotlin Varargs Keyword Useless? A Deep Dive into JetBrains/kotlin](/jetbrains/kotlin/is-kotlin-varargs-useless)

Discover why the Kotlin varargs keyword isn't useless. Explore its syntactic sugar, Java interoperability, and role in compiler infrastructure and bytecode generation.

- Tags: deep-dive
- Published: 2026-02-14

### [How to Create a Kotlin List: The Simplest Methods Explained](/jetbrains/kotlin/how-to-create-simplest-kotlin-list)

Discover the simplest methods to create a Kotlin list. Learn to use listOf() for immutable lists and mutableListOf() for modifiable collections in Kotlin.

- Tags: tutorial
- Published: 2026-02-14

### [How to Initialize an Array in Kotlin with Values: Complete Guide](/jetbrains/kotlin/how-to-initialize-array-in-kotlin-with-values)

Initialize an array in Kotlin with values using arrayOf(). Learn this efficient method for creating fixed-size arrays with automatic type inference and zero overhead.

- Tags: how-to-guide
- Published: 2026-02-13

### [Primary and Secondary Constructors in a Kotlin Class: Delegation and Initialization Explained](/jetbrains/kotlin/what-is-relationship-primary-secondary-kotlin-class-constructor)

Master Kotlin constructors Learn primary and secondary constructor delegation and initialization for robust object creation Ensure consistent object setup in your Kotlin classes.

- Tags: deep-dive
- Published: 2026-02-13

### [Kotlin Switch: Implementing Switch-Case Functionality with the `when` Expression](/jetbrains/kotlin/how-to-implement-kotlin-switch)

Learn how to implement switch case logic in Kotlin using the versatile when expression. Discover its powerful features like exhaustive checking and smart casts for efficient code.

- Tags: how-to-guide
- Published: 2026-02-13

### [Why Kotlin Companion Objects Replace Java Static Fields: JVM Compilation Deep Dive](/jetbrains/kotlin/why-use-kotlin-companion-object-replacement-java-static-fields)

Discover why Kotlin companion objects replace Java static fields. Learn how the Kotlin compiler transforms them into JVM bytecode, offering OO syntax and inheritance.

- Tags: deep-dive
- Published: 2026-02-12

### [Extension Function Kotlin vs Member Function: Core Differences and When to Use Each](/jetbrains/kotlin/difference-member-function-vs-extension-function-kotlin-when-use)

Explore Kotlin extension functions vs member functions. Learn their core differences and when to use extension functions to add behavior to existing types without inheritance.

- Tags: deep-dive
- Published: 2026-02-12

### [What Does the Kotlin Elvis Operator Do? A Deep Dive into ?: Syntax](/jetbrains/kotlin/what-is-kotlin-elvis-operator)

Understand the Kotlin Elvis operator ?: Learn how it handles null values by returning the left operand if non-null, or the right operand if null. Master this concise syntax.

- Tags: deep-dive
- Published: 2026-02-12

### [Kotlin Sealed Class: Complete Guide to Closed Hierarchies and Exhaustive When](/jetbrains/kotlin/what-is-kotlin-sealed-class)

Master Kotlin sealed class for closed hierarchies and exhaustive when expressions. Learn how this powerful feature simplifies state management and error handling in your code.

- Tags: deep-dive
- Published: 2026-02-12

### [Kotlin Ternary Operator: Why `if` Replaces the Classic `? :` Syntax](/jetbrains/kotlin/what-is-kotlin-ternary-operator-logic)

Learn why Kotlin's if expression replaces the classic ternary operator for concise conditional logic. Discover the idiomatic Kotlin approach to conditional assignments.

- Tags: internals
- Published: 2026-02-12

### [How to Use a For Loop in Kotlin: Syntax, Ranges, and Compiler Internals](/jetbrains/kotlin/how-to-use-for-loop-in-kotlin)

Master Kotlin for loops with syntax examples, range usage, and compiler insights. Learn to iterate efficiently over collections, arrays, and more in your code.

- Tags: how-to-guide
- Published: 2026-02-12

