Instead of Vehicle shouldn't it be Myclass | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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(); } }

30th Jul 2020, 1:18 PM
Mallika Gupta
5 Respostas
+ 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..
30th Jul 2020, 1:20 PM
Jayakrishna šŸ‡®šŸ‡³
+ 2
But if this is only the code then it is wrong na..means nothing is there in previous lessons related to this.
31st Jul 2020, 8:58 AM
Mallika Gupta
+ 1
Ohhh I'll check it thenšŸ˜…
31st Jul 2020, 8:56 AM
Mallika Gupta
+ 1
Mallika Gupta ya it is not complete.. because you, don't have Vehicle class, therefore you cannot instantiate it
31st Jul 2020, 4:47 PM
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ 
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ  - avatar
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).
30th Jul 2020, 1:27 PM
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ 
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ  - avatar