Neo

  • 8
  • Locked
Let's initialize our first user under the name Neo. To do this, implement the DBObject interface and its initializeIdAndName method in the User class so that the program runs and displays "The user's name is Neo, id = 1".
You can't complete this task, because you're not signed in.
Comments (11)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Hoist
Level 21 , San Diego, United States
5 March, 04:11
Finally -- that took 1 year. The user's name is Neo, id = 1
Karas Java Developer
21 November 2020, 01:13
The answer to this is... public. This little word placed correctly in the correct place solves a lot. Litterally just follow the requirements. Also the word static, if I am not wrong, this in itself allows a method to be called even if the instance has not been created, as it is being created at the same time. right? thus you can return this as the requirement requires.
yehuda b
Level 23 , Beersheba, Israel
20 May 2020, 17:31
How is can the User be instantiated? isn't it a static class? or maybe because it calls the initialize method right away, it is valid? but why?
Andrew Evans
Level 17 , San Jose, Canada
27 February 2022, 21:50
A static inner class can be instantiated without the need for an instance of the outer class. In general, an Inner class is a part of nested class, called Non-static nested classes in Java.
IO.Error
Level 24 , Bremen, Germany
19 February 2020, 22:15
IO.Error
Level 24 , Bremen, Germany
19 February 2020, 22:14
Can someone give some more details please ? The user's name is Neo, id = 1 Neo is instance of DBObject : true Neo is instance of User : true getclass() returns Matrix.NEO : User Process finished with exit code 0 If I change the return type to user I still get: The user's name is Neo, id = 1 Neo is instance of DBObject : true Neo is instance of User : true getclass() returns Matrix.NEO : User Process finished with exit code 0 I assume this is because : public static DBObject NEO = new User().initializeIdAndName(1, "Neo"); I had to change the return type in the method initializeIdAndName for it to verify - ok. But why do I have to change the return type in the first place ? How can I verify in the code what's going on ? instanceof and getclass() don't seem to help ... Thanks a lot
Roman
Level 41
20 February 2020, 12:11
Please refer to Help section at our course.
Hoist
Level 21 , San Diego, United States
5 March, 04:12
HELP section discussion -- https://codegym.cc/help/7613
Muhammad Vahhaaj
Level 19 , Rawalpindi, Pakistan
28 July 2019, 17:25
How is this even a thing. In some lesson it was said that to override/implement a method its signature must be the same :-/
Asma Sadia
Level 15 , Brooklyn, United States
17 January 2020, 04:55
Yes. Can someone explain this?
5 August 2020, 00:03
Seems like Interface and Class types are interchangeable, but doesn't explain why it still implements interface method with the different signature.