[5923] in java-interest
tutorial question
daemon@ATHENA.MIT.EDU (Brad Q. Lucht)
Tue Mar 5 01:09:11 1996
Date: Mon, 04 Mar 1996 22:12:03 -0600
To: java-interest@java.sun.com
From: "Brad Q. Lucht" <blucht@sound.net>
Cc: lemay@lne.com, virtual@rendezvous.com
I am working through "Teach Yourself Java in 21 Days;" at this point it is
more like 21 weeks.
I have a question about error statements I receive when I compile an example:
Motorcycle.java:1: Identifier expected.
public static void main (String args[]) {
^
Motorcycle.java:1: 'class' or 'interface' keyword expected.
public static void main (String args[]) {
^
2 errors
For the life of me, I can't see what is wrong here. Any explanation or
guidance are appreciated
Here is the example, as I have typed it in:
public static void main (String args[]) {
Motorcycle m = new Motorcycle();
m.make = "yamaha RZ350";
m.color = "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();
}
class Motorcycle {
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 showAtts() {
System.out.println("This motorcycle is a "
+ color + " " + make);
if (engineState == true)
System.out.println("The engine is on.");
else System.out.println("The engine is off.");
}
}
-- Brad Lucht
blucht@sound.net
SD Engineering & Statistics
Creative Thinking - Problem Solving
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com