Types of classes in Kotlin
- Regular class
- Data Class
- Sealed Class
- Abstract Class
- Interface Class
- Singleton in Kotlin
- Enum Class
- Inline Class
- Companion Object
Class Type | Purpose |
---|---|
Regular Class | General object-oriented programming |
Data Class | Stores data with built-in utility methods |
Sealed Class | Restricts subclass hierarchy (useful for when ) |
Abstract Class | Base class with abstract methods |
Interface Class | Defines behavior for multiple classes |
Singleton in Kotlin | Singleton instance |
Companion Object | Static-like members in a class |
Enum Class | Represents a fixed set of constants |
Inline Class | Wraps a single value with low memory overhead |