Error compiling basic java code
Posted
by
Michael Younani
on Stack Overflow
See other posts from Stack Overflow
or by Michael Younani
Published on 2013-06-27T04:17:12Z
Indexed on
2013/06/27
4:21 UTC
Read the original article
Hit count: 169
New to java. Practicing coding by following a book.
Heres my code:
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.");
}
}
}
When I compile I get 2 errors:
1) illegal start of expression 2) ; expected
I can't pin point the problem. If anyone can direct me or hint me please do.
© Stack Overflow or respective owner