Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: Help with Symbol Error

  1. #1
    TANKDS is offline Member
    Join Date
    Feb 2012
    Posts
    54
    Rep Power
    0

    Default Help with Symbol Error

    I am following the Oracle tutorials for learning Java and I tried to compile the example code but it returned the "cannot find symbol error". Please Help!
    Java Code:
    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();
        }
    }
    Java Code:
    BicycleDemo.java:6: error: cannot find symbol
    Bicycle bike 1 = new Bicycle();
    ^
    symbol: class Bicycle
    location: class BicycleDemo
    BicycleDemo.java:6: error: cannot find symbol
    Bicycle bike 1 = new Bicycle();
                                ^
    symbol: class Bicycle
    location: class BicycleDemo
    BicycleDemo.java:7: error: cannot find symbol
    Bicycle bike 2 = new Bicycle();
    ^
    symbol: class Bicycle
    location: class BicycleDemo
    BicycleDemo.java:7: error: cannot find symbol
    Bicycle bike 2 = new Bicycle();
                                ^
    symbol: class Bicycle
    location: class BicycleDemo
    4 errors
    Last edited by TANKDS; 02-06-2012 at 09:58 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Help with Symbol Error

    The error is very explicit: the compiler cannot find a class named Bicycle.

    Have you created a Bicycle class or are you skipping ahead in the tutorial without going through the earlier steps?

    db
    TANKDS likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    TANKDS is offline Member
    Join Date
    Feb 2012
    Posts
    54
    Rep Power
    0

    Default Re: Help with Symbol Error

    is this the code for the class? and where does it need to be?
    Java Code:
    class Bicycle {
    
        int cadence = 0;
        int speed = 0;
        int gear = 1;
    
        void changeCadence(int newValue) {
             cadence = newValue;
        }
    
        void changeGear(int newValue) {
             gear = newValue;
        }
    
        void speedUp(int increment) {
             speed = speed + increment;   
        }
    
        void applyBrakes(int decrement) {
             speed = speed - decrement;
        }
    
        void printStates() {
             System.out.println("cadence:" +
                 cadence + " speed:" + 
                 speed + " gear:" + gear);
        }
    }

  4. #4
    TANKDS is offline Member
    Join Date
    Feb 2012
    Posts
    54
    Rep Power
    0

    Default Re: Help with Symbol Error

    Never mind, your input has allowed me to fix it myself, thank you.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Help with Symbol Error

    Quote Originally Posted by TANKDS View Post
    is this the code for the class? and where does it need to be?
    Um, you said
    Quote Originally Posted by TANKDS View Post
    I am following the Oracle tutorials for learning Java
    It's all there in the tutorials. Why should anyone have to repeat the same things here?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Cannot Find Symbol Error
    By javadummy1 in forum New To Java
    Replies: 6
    Last Post: 04-09-2011, 11:13 AM
  2. Please help- Error: cannot find symbol
    By Avthar in forum New To Java
    Replies: 4
    Last Post: 02-28-2011, 08:34 AM
  3. I need help with an error! Cannot find symbol error!
    By ambria1975 in forum New To Java
    Replies: 2
    Last Post: 07-07-2010, 02:37 AM
  4. Cannot find symbol error
    By rajivjoshi in forum New To Java
    Replies: 3
    Last Post: 05-31-2010, 11:13 AM
  5. Replies: 9
    Last Post: 10-18-2008, 09:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •