Buggy initializeIdAndName

  • 8
  • Locked
Something's wrong with this code! Your task is to fix the program so that it compiles and runs. First, figure out why it isn't working and then implement the initializeIdAndName method in the User class. In this case, the User class's initializeIdAndName method must return a User.
You can't complete this task, because you're not signed in.
Comments (7)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Jonaskinny Java Developer at Sandmedia
26 February 2022, 05:00
Cast (which they taught how to do) fails, yet implicit cast succeeds, even though its likely identical byte code. Tells me the validator is not using byte code, so don't waist attempts doing things correctly when they are not teaching that exact thing in this exact lesson.
Samuel Michael
Level 16 , Stafford, United States
Expert
19 February 2021, 04:19
Why is returning "this" the correct answer? What does it mean?
Karas Java Developer
1 March 2021, 19:09
Long story short, this is the created object in itself. So the User class when called to create a User it is created and thus it can be returned with the values that are being passed. Latter in this course you will see the sequence of how variables are initiated etc.and in some other prior refferences also you can find what this is, to get more understanding, I really cut corners here.
28 August 2020, 02:42
what does it mean to "return this;" ?
Devonte A
Level 18 , Rubery, United Kingdom
30 June 2020, 15:51
Tip - Do not return a DBObject instead return a User to the initializeIdAndName in the user class.
Oliver Heintz
Level 18 , Mustang, United States
30 November 2020, 14:52
Ha! I was wondering why I failed verification. It seemed to work fine. You probably saved me hours of head scratching.
Oliver Heintz
Level 18 , Mustang, United States
3 December 2020, 17:19
I literally did the same freakin' thing in the last tasks of the lesson! I'm so stupid!