Nothing & Any

KOTLIN › Types & Classes

Kotlin's type hierarchy: Any as the root of all non-nullable types, Nothing as the bottom type with zero instances.

Understanding Nothing and Any reveals how Kotlin's type system actually works under the hood. Interviewers use these to separate candidates who can reason about types from those who just memorise syntax. Expect questions on why throw is an expression of type Nothing, how emptyList() is backed by a List<Nothing> singleton that assigns to any List<T>, what Nothing? means, and where Any sits relative to Java's Object. These come up in generics, error handling, and sealed-hierarchy design.

What this covers

Study this topic

Further reading