java新手。遵循一本書來練習編碼。編譯基本java代碼時出錯
繼承人我的代碼:
class Motorcycle {
//Three instance variables - make and color are strings. while a boolean refers to TRUE OR FLASE(in this case off or on)
String make;
String color;
boolean engineState;
void startEngine() {
if (engineState == true)
System.out.print("The engine is already on.");
else {
engineState = true;
System.out.print("The engine is now on.");
}
void showAtts() {
System.out.print("This motorcycle is a " + color + " " + make);
if (engineState ==true)
System.out.print("The engine is on.");
else System.out.print("The engine is off.");
}
}
}
我編譯時獲得2個錯誤:
1)表達 2的非法啓動);預計
我不能指出問題。如果有人能指導我或暗示我,請做。
使用IDE,如[NetBeans](https://netbeans.org/),[Intellij](http://www.jetbrains.com/idea/)或[Eclipse](http:// www。 eclipse.org/downloads/)真的可以幫助避免這樣的錯誤。我認爲甚至像[Notepad ++](http://notepad-plus-plus.org/)和[JEdit](http://www.jedit.org/)這樣的基本編輯器都有一些語言支持(在語法高亮方面和支架匹配) –
聽起來很棒的建議。現在下載。 – KKP