Object Declarations
Last updated
What is Object Declarations?
Object declarations in Kotlin provide a way to define a singleton object. This means you create a class and simultaneously declare a single instance of it. The object is initialized lazily when it's accessed for the first time. You can define properties, functions, and even inherit from classes and interfaces within an object declaration. They are useful for creating utility classes or managing shared resources where only one instance is needed.
Free resources to learn Object Declarations
- Official docsObject declarations and expressions
- ArticleKotlin Object Declarations and Expressions
More in stage 23: Class Members
Object Declarations: common questions
Can I learn Object Declarations in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Object Declarations in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Object Declarations tutorial for beginners?
It is lesson 74 of 153 in the free Kotlin roadmap, in stage 23, Class Members. If you are new to Kotlin, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.