Skip to main content

i tried every means and i cant solve it......help

4 replies [Last post]
sd1239
Offline
Joined: 2013-01-06
Points: 0

I followed the instruction by java tutorial and there was a problem when running it

program :

package bicycledemo;

/**
*
* @author SKY WHY
*/
class BicycleDemo {
public static void main(String[] args) {

// Create two different Bicycle objects
Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();

// Invoke methods on those objects
bike1.changeCadence(50);
bike1.speedUp(10);
bike1.changeGear(2);
bike1.printStates();

bike2.changeCadence(50);
bike2.speedUp(10);
bike2.changeGear(2);
bike2.changeCadence(40);
bike2.speedUp(10);
bike2.changeGear(3);
bike2.printStates();
}
}

result :

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol: class Bicycle
location: class bicycledemo.BicycleDemo
at bicycledemo.BicycleDemo.main(BicycleDemo.java:15)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
samdaniel
Offline
Joined: 2013-08-06
Points: 0

Create a new class named as ''Bicycle'' followed by this code and within that class define the methods you have called like ''speedUp(), changeGear(), etc''. Then it will work.

extro
Offline
Joined: 2013-05-03
Points: 0

You created two instance of a class of Bicycle

Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();
but does it really exist? if so where is it? and hope u know that all the methods you mention should be created. You really need to go back and study Objects, Method and Constructors in Java. Good luck..

sudhir.mishra
Offline
Joined: 2013-02-01
Points: 0

Check for the class Bicycle, is it in the same package as BicycleDemo ? If not you got to add an import for the Bicycle class.

Hope this helps.

-sudhir

carey88
Offline
Joined: 2013-09-26
Points: 0

sudhir.mishra wrote:
Check for the class Bicycle, is it in the same package as BicycleDemo ? If not you got to add an import for the Bicycle class.

Hope this helps.

-sudhir

What do you mean by "add an import"? you mean I import the Bicycle class? I am so confused.