0
Instead of Vehicle shouldn't it be Myclass
class MyClass { public static void main(String[ ] args) { Vehicle v1 = new Vehicle(); Vehicle v2 = new Vehicle(); v1.color = "red"; v2.horn(); } }
5 odpowiedzi
+ 2
You missing Vehicle class defination.. See again carefully where you got this...!
Edit:
Mallika Gupta
In the previous topic, there explained how to create a class and in next topic, it is explained how to create an object to that class and how to assign object variables for the same previous example. So There is a continuation.. And also how to merge those into one, is shown in example...
Look for that by hitting "try your self" option there for full program...
Use that "try yourself" in all, that help you more..
+ 2
But if this is only the code then it is wrong na..means nothing is there in previous lessons related to this.
+ 1
Ohhh I'll check it then😅
+ 1
Mallika Gupta ya it is not complete.. because you, don't have Vehicle class, therefore you cannot instantiate it
0
u missed the previous topic I believe., Defining Attributes, this example is from Java Course , "Classes and Objects" lesson.
The topics within a lesson are interlinked, so some part of the code exists in previous topics (as in this case).