我想以后我成功编译它的载重车辆类,但这个错误occures: Error: could not find or load main class Vehicle
Java错误:找不到或无法加载主类车辆
我认为有可能是在我的代码错误,其中是以下内容:
public class Vehicle
{
String make;
String color;
boolean engineState;
void startEngine()
{
if (engineState == true)
System.out.println("The engine is already on!");
else
{
engineState = true;
System.out.println("The engine is now on.");
}
}
void showAttributes()
{
System.out.println("This vehicle is a " + color + "
" + make);
if (engineState == true)
System.out.println("The engine is on.");
else
System.out.println("The engine is off.");
}
public static void main(String args[])
{
// Create a new vehicle and set its attributes.
Vehicle car = new Vehicle();
car.make = "Rolls Royce";
car.color = "Midnight blue";
System.out.println("Calling showAttributes ...");
car.showAttributes();
System.out.println("--------");
System.out.println("Starting the engine ...");
car.startEngine();
System.out.println("--------");
System.out.println("Calling showAttributes ...");
car.showAttributes();
// Let’s try to start the engine again.
System.out.println("--------");
System.out.println("Starting the engine ...");
car.startEngine();
}
}
错误不在您的代码中,而是在您用来启动它的命令中。 – 2013-03-04 11:34:44
你是什么意思? – 2013-03-04 14:10:49
我的意思是你发布了所有不相关的信息,而且没有任何相关的信息。就目前而言,你无法帮助解决这个问题。 – 2013-03-04 14:27:29