Well, I understand that dog1, dog2 and so on are variables of type Dog that is created by Class Dog. I understand that we creating two new objects too. But now I dont quite get it what these objects really are. Since "Dog" appears twice in this context I conclude that it is not object's name but object's type. But what does that mean exactly? And what command like "dog2.name ="Bella";" is and what it supposed to do?
Meaning of activities performed in the task.
You must be signed in to leave a comment
3 August 2019, 02:16
Let me try to explain it to you. In the lower part of the code,you created a class called Dog that has only one atribute to it: a String called name ( I don't know if atribute is the correct word but for the sake of the explanation let's use it). On the top part of your code, you created 3 variables of the class Dog, dog1,dog2 and dog3. And these 3 variables are able to store only one atribute, the name atribute. So, what you are saying is that the atribute name of the dog2 variable is gonna be Bella, dog2.name = "Bella". I saw some people saying that this is called referencing on Java and would go something like this Ob1.name = Obj2. Lesson 6 of level 2 has an explanation about this that I think will help.