why the code is not working? Kindly help me in locating the error. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why the code is not working? Kindly help me in locating the error.

public class Vehicle { int maxspeed; int wheels; String color; double fuelCapacity; void horn() { System.out.println("Beep!"); } } class MyClass { public static void main(String[ ] args) { Vehicle v1 = new Vehicle(); Vehicle v2 = new Vehicle(); v1 color = "red"; v2 horn(); } } result: ./Playground/MyClass.java:9: error: ';' expected v2 horn(); ^ 1 error why it is so...??? Kindly help

23rd Apr 2020, 7:34 AM
kp kalia
kp kalia - avatar
1 Answer
+ 2
v2.horn();
23rd Apr 2020, 7:39 AM
Avinesh
Avinesh - avatar