Constructors

Learn about Kotlin constructors, including primary and secondary constructors, property initialization, and default values.

When we create an object, we often want to initialize it with specific values. This is what we use constructors for. As we’ve seen already, when no constructors are specified, an empty default constructor is generated with no parameters.

Get hands-on with 1200+ tech skills courses.