public User initializeIdAndName(long id, String name){
this.id = id;
this.name = name;
return this;
}
hidden #10486986
Level 15
what does it mean to "return this;" ?
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Nouser
28 August 2020, 07:08
the current object
here the current object is eg. a new User. No fields have been initialized. That here's done not with a constructor but with a method that returns that object.
DBObject NEO = new User().initializeIdAndName(1, "Neo");
or
DBObject NEO = new User();
NEO.initializeIdAndName(1, "Neo");
+2