Creating instances without new keyword
📖 Scenario: Imagine you are building a simple app to manage books in a library. You want to create book objects to store information about each book.
🎯 Goal: You will create instances of a Book class without using the new keyword, which is not used in Kotlin. You will then print the details of the book.
📋 What You'll Learn
Create a data class called
Book with properties title and authorCreate an instance of
Book without using newPrint the book details using string interpolation
💡 Why This Matters
🌍 Real World
Creating instances without the <code>new</code> keyword is common in Kotlin and many modern languages. It makes code cleaner and easier to read.
💼 Career
Understanding how to create and use class instances is fundamental for Kotlin developers working on Android apps, backend services, or any Kotlin-based projects.
Progress0 / 4 steps