In Java I have these two classes :
public class Base {
protected Long id;
// getter setter
}
public User extends Base {
private String name;
private Integer age;
public User(Long id) { this.id = id; }
// getter setter
}
I created these two classes in Kotlin :
open class Base(var id: Long? = null)
class User(
var id: Long? = null,
var name: String? = null,
var age: Int? = null
) : Base()
Now in Java I want to call the User() constructor with only the 'id' parameter :
new User(5);
This seems wrong to me, because by doing this I re-declared the "id" field in the User class.
How can I set the id field of the base class in Kotlin (like I did in Java with "this.id = id;" ?
User extends Base