• Post Reply Bookmark Topic Watch Topic
  • New Topic

Irreconcilable Oracle demo  RSS feed

 
Kerry Cotter
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I copied code from:

http://docs.oracle.com/javase/tutorial/java/concepts/examples/BicycleDemo.java

as follows:



I got the following message:

Bicycle.java:58: class, interface, or enum expected
void printStates() {
^
Bicycle.java:62: class, interface, or enum expected
}
^
2 errors
Kerry-Cotters-iMac:introcs kcotter01$ javac Bicycle.java
Bicycle.java:58: class, interface, or enum expected
void printStates() {
^
Bicycle.java:62: class, interface, or enum expected
}
^
2 errors
Kerry-Cotters-iMac:introcs kcotter01$ javac Bicycle.java
Bicycle.java:11: cannot find symbol
symbol : method changeCadence(int)
location: class Bicycle
bike1.changeCadence(50);
^
Bicycle.java:12: cannot find symbol
symbol : method speedUp(int)
location: class Bicycle
bike1.speedUp(10);
^
Bicycle.java:13: cannot find symbol
symbol : method changeGear(int)
location: class Bicycle
bike1.changeGear(2);
^
Bicycle.java:14: cannot find symbol
symbol : method printStates()
location: class Bicycle
bike1.printStates();
^
Bicycle.java:16: cannot find symbol
symbol : method changeCadence(int)
location: class Bicycle
bike2.changeCadence(50);
^
Bicycle.java:17: cannot find symbol
symbol : method speedUp(int)
location: class Bicycle
bike2.speedUp(10);
^
Bicycle.java:18: cannot find symbol
symbol : method changeGear(int)
location: class Bicycle
bike2.changeGear(2);
^
Bicycle.java:19: cannot find symbol
symbol : method changeCadence(int)
location: class Bicycle
bike2.changeCadence(40);
^
Bicycle.java:20: cannot find symbol
symbol : method speedUp(int)
location: class Bicycle
bike2.speedUp(10);
^
Bicycle.java:21: cannot find symbol
symbol : method changeGear(int)
location: class Bicycle
bike2.changeGear(3);
^
Bicycle.java:22: cannot find symbol
symbol : method printStates()
location: class Bicycle
bike2.printStates();
^
11 errors


What gives?
 
Mark Beardsley
Ranch Hand
Posts: 32
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error messages are trying to tell you that there are members missing from the Bicycle class; in this case, the methods changeCadence(), speedUp(), etc have not been declared nor defined withint your source code file.

I suspect that if you dig around in the tutorial text, you will find the source code for these methods.

You might start here for instance - http://docs.oracle.com/javase/tutorial/java/javaOO/classes.html
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must have copied the code wrong. There is an extra bracket (}) someplace.
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code you provided is the BicycleDemo class, not the Bicycle class. You need both files.

http://docs.oracle.com/javase/tutorial/java/concepts/examples/Bicycle.java
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!