I am a newbie in Java, although I have knowledge of Object Oriented Programming from Python but I'm currently having problem understanding this example on creating public class either combining the classes together or in different files and then compile them
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();
}
}
The example above was given at Sololearn where I am currently learning, but it only works in Sololearn java compilers. Other compiles throw error
Unable to find static main(String[]) in vehicle
Or main method not found
Vehicleclass instead ofMyClass