M
M Wilson
Hi,
Just started learning java and can't get the following example to work. It
compiles OK but returns the following error when run:
Exception in thread "main" java.lang.NoClassDefFoundError: Motorcycle/class
I would be grateful for any help
Thanks, Matt
class Motorcycle {
String make;
String colour;
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 showAtts() {
System.out.println("This motorcycle is a " + colour + " " + 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[]) {
Motorcycle m = new Motorcycle();
m.make = "Yamaha RZ350";
m.colour = "yellow";
System.out.println("Calling showAtts...");
m.showAtts();
System.out.println("-----");
System.out.println("Starting engine...");
m.startEngine();
System.out.println("-----");
System.out.println("Calling showAtts...");
m.showAtts();
System.out.println("-----");
System.out.println("Starting engine...");
m.startEngine();
}
}
Just started learning java and can't get the following example to work. It
compiles OK but returns the following error when run:
Exception in thread "main" java.lang.NoClassDefFoundError: Motorcycle/class
I would be grateful for any help
Thanks, Matt
class Motorcycle {
String make;
String colour;
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 showAtts() {
System.out.println("This motorcycle is a " + colour + " " + 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[]) {
Motorcycle m = new Motorcycle();
m.make = "Yamaha RZ350";
m.colour = "yellow";
System.out.println("Calling showAtts...");
m.showAtts();
System.out.println("-----");
System.out.println("Starting engine...");
m.startEngine();
System.out.println("-----");
System.out.println("Calling showAtts...");
m.showAtts();
System.out.println("-----");
System.out.println("Starting engine...");
m.startEngine();
}
}