The first thing a person/robot/variable receives after it is born/spawned/created is a name. Our brains aren't very comfortable with the idea of a world without names and titles. Let's come to their rescue: let's create a special automated naming method that sets the value of the private String variable name, i.e. names the object.
What's the cat's name?
- 4
Locked
Comments (11)
- Popular
- New
- Old
You must be signed in to leave a comment
Michael Scanlan
27 January 2021, 01:07
Hope this link helps someone else as well. It provides a list of Java commands with explanations and helped me figure out some of these exercises:
• Java Command Explenations
0
Constantin Anton
27 August 2020, 10:15
Does this.name is the name inside the method and normal name is the global one inside Class ?
0
Andrei
4 September 2020, 14:27
This is what I am thinking yes. But it does not accept name = this.name.
0
Constantin Anton
2 January 2021, 14:26
Hard for us romanian native speakers to properly understand english requirements. I can see you level up so you fixed this ?
0
Andrei
4 January 2021, 08:18
Yes, I did all of them, even though it was very difficult. But it is worth it.
0
Gregory
26 January 2020, 17:35
looking at the previous example I did
Cat.name = name;
why is this wrong.
I am so confused when to use this. and when to use Cat.
0
JAKUB
10 March 2020, 14:28
lI'm late, but still:
You should use this.name instead of cat.name
it's something with visibility of variables - method setName can't see class Cat - but I have no idea why
+2
Liew
16 April 2020, 03:55
Cat.name is to be used only when you are using static variables that cannot be changed.For none static and declared in a class, you should use this.blahblahblah
+3
peter
3 August 2020, 22:21
thank you this was really helpful
0
Tyler Evans
20 August 2020, 20:39
Thank JAKUB you beautiful man. you get a kudos from me.
0
~mK
25 December 2019, 19:35
What is wrong here. It compiles and uses the argument
0