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