2 ms·
How do they relate to Java’s records?
by kaba0 3y ago
How do they relate to Java’s records?
- p2detar 3y agoThey do have similarities, but data classes actually predate records. One can declare a data class a record by using the @JvmRecord annotation, which probably introduces some JVM benefits in how records are represented in the Java memory model. All in all you could use a Kotlin data class just like you'd use a Java record, but it gives you much more flexibility like inheritance and mutable fields.