Kotlin keywords are reserved words that define the syntax and structure of the language. They help create variables, functions, classes, control flow logic, and more. Organizing keywords by category makes it easier to understand their roles in a Kotlin program.
Declaration Keywords
- fun – Declares a function.
- class – Declares a class.
- object – Declares a singleton object.
- interface – Declares an interface.
- val – Declares an immutable (read-only) variable.
- var – Declares a mutable (read-write) variable.
- typealias – Creates a type alias.
- constructor – Declares a primary or secondary constructor.
Modifier Keywords
- open – Allows a class or method to be overridden.
- override – Overrides a superclass method or property.
- abstract – Declares an abstract class or function.
- final – Prevents overriding (default in Kotlin).
- private, protected, internal, public – Control visibility.
- lateinit – Delays initialization of a non-null property.
- const – Declares a compile-time constant.
- companion – Declares a singleton inside a class.
- inline – Inlines function calls at compile time.
- data – Creates a data class with auto-generated methods.
- sealed – Restricts subclassing to a known set of types.
- enum – Declares an enumeration.
Control Flow Keywords
- if, else – Conditional branching.
- when – Replaces
switch; used for branching logic. - for, while, do – Looping constructs.
- break, continue – Control loop execution.
- return – Returns a value from a function or lambda.
Exception Handling Keywords
- try, catch, finally – Handle exceptions.
- throw – Throws an exception explicitly.
Type and Cast Keywords
- is – Checks if an object is of a given type.
- as – Casts an object to another type.
- null – Represents a null reference.
Delegation & Property Keywords
- by – Used for interface or property delegation.
- lazy – Delegate that initializes a value only once on first access.
- observable – Delegate that listens to property changes.
- vetoable – Delegate that can reject property changes based on conditions.
Object & Scope Keywords
- this – Refers to the current object instance.
- super – Refers to the superclass implementation.
- in – Used for ranges and collection membership (e.g.,
x in list). - out, in (variance modifiers) – Used in generics for type projection.
Miscellaneous Keywords
- typeof – Gets the type information (used in
reifiedgenerics). - field, get, set – Used in custom property accessors.
- package, import – Manage namespaces and external classes.