Getters and setters for the Dog class

  • 4
  • Locked
Let's create a Dog class. A dog should have a name and age, and getters and setters for these variables. A getter is a method that returns a variable's current value to the caller. A setter is a dog breed. However, though we are talking about dogs at the moment, this term actually isn't about dogs: in the context of programming, a setter is a method that sets a variable to a new value.
You can't complete this task, because you're not signed in.
Comments (9)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 11 , Bucharest, Romania
14 August 2020, 17:22
could someone told me what is wrong with my code please?
Level 41
17 August 2020, 05:29
Please post your question with the attached solution in the section Help.
Level 41
17 August 2020, 05:43
Please post your question with the attached solution in the section Help.
Marvin Ellis
Level 7 , Peoria, Canada
13 July 2020, 02:47
I don't understand whats wrong on "';' expected. file com/codegym/task/task05/task0503/, line 18, position 302"
Level 19 , Moscow, Russia
6 May 2020, 09:43
(IntelliJ IDEA) Alt + Insert -> Getter and Setter -> Ctrl + (click all variables we need) -> OK ☑ done
carlos oliveira
Level 10 , Seattle, United States
29 March 2019, 19:55
the same happened in my code..
Level 8 , Bangalore, India
14 September 2018, 10:16
Is it mandatory that the getters and setters have the second part of the method name begin with a capital letter? I typed getname and setname first, which errored out. Later tried getName and setName and it worked. It would be helpful to call it out during the description in the previous lesson.
Lijo M Loyid
Level 7 , Delhi, India
16 March 2019, 11:42
It is just a Java beans convention
Kent Hervey Software Engineer/Consult at Zeal IT ConsultantsExpert
15 October 2019, 23:17
Yes. It is called Camel Case and it is mandatory