Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Help me with a 'Can not find symbol' error

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help me with a 'Can not find symbol' error

    Hi,

    I just started learning Java. As part of the learning, i am working with small examples which are available from the book.
    I have written the below program and while compiling i am getting error. The program and error details goes as follows,

    //compute distance of light travels using Java long variable.
     
     class Light {
     
    public static void main(String args[]) {
     
    int lightspeed;
    long days;
    long seconds;
    long distance;
     
    // approximate speed of light in miles per second
     
    light speed = 186000;
     
    days = 1000; //specifying the number of days here
     
    seconds = days * 24 * 60 * 60; //convert to seconds
     
    distance = lightspeed * seconds; //compute distance
     
    System.out.print("In " + days);
    System.out.print(" days light will travel about ");
    System.out.print(distance + " miles ");
      }
    }

    I have given the Java file name as 'Light.java'. I have also verified the availability of the java file and compilation path. both are matching. Also, Java file name and class name defined are also same.

    Please help me with this.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,066
    My Mood
    Mellow
    Thanks
    184
    Thanked 652 Times in 639 Posts

    Default Re: Help me with a 'Can not find symbol' error

    Please post the entire text of errors and the associated stack trace. The text contains information that is helpful and you should understand.

    Please properly indent your code. All lines starting at the left column is more difficult to read.

    Your error is due to a typo on line 14 of what you posted.

  3. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me with a 'Can not find symbol' error

    Thanks for the reply....
    I am attching the complete error details to this reply.

    Compilation Error.jpg

    By the way, i didnt understand your comment, " Please properly indent your code. All lines starting at the left column is more difficult to read.".
    I am sorry, if you feel this is a silly question as i am newbie to Java programming.....

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,066
    My Mood
    Mellow
    Thanks
    184
    Thanked 652 Times in 639 Posts

    Default Re: Help me with a 'Can not find symbol' error

    Did you find the typo on line 14?

    You've asked no silly questions so far.

    As for my indent comment, there are various style guides on the topic available on the 'net, search 'java style guide'. Google may have the most authoritative and oft referenced, but if you take a course be sure to write your code according to your instructor's style requirements. Outside academia, the goal is to make your code as easy to read and understand as possible. This is accomplished in part by writing your code like everyone else's.

  5. #5
    Junior Member
    Join Date
    Jul 2014
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me with a 'Can not find symbol' error

    Ah! Super.....I figured that out. Its about space between light and speed.
    Thanks a ton for helping me out on this.
    per your suggestion, i would go through the 'java style guide' which will improve my style of writing the code.
    Thanks once again for helping me out on this......

Similar Threads

  1. Error:Cannot find Symbol
    By Leonardo1143 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 13th, 2013, 05:40 PM
  2. [SOLVED] cannot find symbol error
    By Topflyt in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 5th, 2011, 08:57 AM
  3. Cannot find symbol ERROR
    By yacek in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 21st, 2011, 11:39 PM
  4. error :cannot find symbol
    By iswan in forum AWT / Java Swing
    Replies: 1
    Last Post: October 1st, 2011, 08:26 AM
  5. Cannot find symbol error
    By AnuR in forum What's Wrong With My Code?
    Replies: 9
    Last Post: February 23rd, 2011, 01:50 PM