Kotlin data class implementing Java interface

前端 未结 2 594
难免孤独
难免孤独 2020-12-17 08:12

I\'m trying to introduce Kotlin into my current project. I\'ve decided to begin with entities, which seem to map perfectly to data classes. For example I have a data class:<

2条回答
  •  悲哀的现实
    2020-12-17 08:46

    If this is your whole data class then you're not overriding getId(). I see that you have a property called id and Kotlin should generate a getter for that but that won't be marked with the override keyword which you need to indicate that you're overriding an abstract function.

    -- EDIT -- Alexander beat me to it! His answer is better anyway! ;)

提交回复
热议问题