General Class VS Data Class in Kotlin
Some main difference between them:
· Data class provides those — toString(), hashCode(), copy(), component(), equals().
· Data class can’t be extended. They are final by default.
· Provides self-generated(boilerplate) code.
· Data class contain only state, doesn’t perform any operations.
· If I have a class that is just meant to store data and not perform any operations, then I’ll use a data class
to simplify my code.
· A data class must be declared with at least one primary constructor parameter which must be declared with val or var. A normal class can be defined with or without a parameter in its constructor.
· Data class only deals with data.