I have this Kotlin data class: ``` class Person(ov...
# announcements
p
I have this Kotlin data class:
Copy code
class Person(override val id: String, val name: String) : HasId
and this Java interface:
Copy code
public interface HasId {
    String getId();
}
How do I implement the interface? The above example gives me
'id' overrides nothing
d
You must declare the
id
val as private and implement
getId
using a
fun
. You will still be able to use the
object.id
syntax when accessing the field.
k