我想以後我成功編譯它的載重車輛類,但這個錯誤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