Questions

Kotlin questions

Choose a question page, learn the concept, then test your understanding with a quiz.

Kotlin Interfaces and SAM Conversion: Why "Interface Does Not Have Constructors" Happens

Learn why Kotlin shows "Interface does not have constructors", how SAM conversion works, and how to instantiate interfaces correctly.

kotlinjava

Kotlin JUnit @Rule Visibility with ActivityTestRule in Android Tests

Learn why Kotlin JUnit @Rule fields fail visibility checks in ActivityTestRule tests and how to fix them with @JvmField.

kotlinandroidtestingandroid-espresso

Kotlin List Casting: Safely Converting List<*> to List<Waypoint> Without Unchecked Cast Warnings

Learn why Kotlin shows unchecked cast warnings for List<*> to List<Waypoint> and how to safely filter and validate typed lists.

kotlinlistgenericscasting

Kotlin List vs MutableList: Why add, remove, and put Are Missing

Learn why Kotlin List and Map do not have add, remove, or put, and how MutableList and MutableMap solve it safely.

kotlincollections

Kotlin Nullable Types: Idiomatic Ways to Handle, Convert, and Assert Non-Null Values

Learn the idiomatic Kotlin ways to handle nullable types, convert to non-null values, and use safe calls, Elvis, and !! correctly.

kotlinnullablenon-nullable

Kotlin Property Initialization: by lazy vs lateinit

Learn when to use Kotlin by lazy or lateinit for property initialization, with examples, differences, mistakes, and practical guidance.

kotlinproperties

Kotlin Public Getter Private Setter for var: How Accessors Work

Learn how to declare a Kotlin var with a public getter and private setter, with syntax, examples, mistakes, and real use cases.

kotlin

Kotlin String Formatting: Format Numbers in String Templates

Learn how to format numbers in Kotlin string templates, including limiting decimal places for Double values with practical examples.

kotlinstring-formatting

Kotlin Ternary Conditional Operator Equivalent Explained

Learn the Kotlin equivalent of the ternary conditional operator and how to use if as an expression with clear examples.

kotlinconditional-operator

Kotlin Void vs Unit vs Nothing: Differences, Uses, and Examples

Learn the difference between Kotlin Void, Unit, and Nothing with clear examples, return type rules, and practical usage patterns.

kotlingenericstypesfunctional-programming

Kotlin and JPA Entities: Default Constructors, Immutability, and Practical Patterns

Learn how Kotlin works with JPA entities, why no-arg constructors matter, and how to handle nullability, immutability, and Hibernate safely.

kotlinhibernatejpadefault-constructor

Kotlin const vs val: What’s the Difference?

Learn the difference between const and val in Kotlin, when to use each, and common mistakes with clear examples.

kotlinconstants

Kotlin switch-case Equivalent: Using when Expression

Learn how to replace Java switch-case in Kotlin using when, with syntax, examples, common mistakes, and real-world usage.

kotlinswitch-statement

Passing Functions as Parameters in Kotlin

Learn how to pass a function as a parameter in Kotlin using function references, lambdas, and matching function types.

kotlin

Room Persistence Library Auto-Increment Primary Key in Kotlin

Learn how to create an auto-increment primary key in Room using Kotlin, with @PrimaryKey(autoGenerate = true) examples and common mistakes.

kotlinandroidandroid-room

Single Exclamation Mark in Kotlin: Boolean Negation and Java Interop

Learn what a single ! means in Kotlin, how boolean negation works, and why it often appears when calling Java APIs.

kotlin

Sort by Multiple Fields in Kotlin: sortedBy, thenBy, and compareBy

Learn how to sort a list by multiple fields in Kotlin using compareBy, thenBy, and sortedWith with clear examples and common pitfalls.

kotlin

Static Extension Methods in Kotlin: What’s Possible and How to Do It

Learn how Kotlin extension functions work, why static extension methods on classes are not supported, and practical alternatives to use instead.

kotlinstatic-methods

Swift `if let` Equivalent in Kotlin: Safe Null Handling with `let`, `?.`, and `if`

Learn the Kotlin equivalent of Swift `if let` for nullable values using safe calls, `let`, Elvis, and null checks with clear examples.

kotlin

Understanding the Kotlin Plugin Version Warning in Gradle for Android and Java Modules

Learn why Android Studio shows a Kotlin plugin version warning in Gradle, even when versions match, and how to handle it correctly.

kotlinandroidandroid-studiogradle

Page 5 of 6 - 112 questions