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 10 of 10

Thread: can't find symbol - variable error

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default can't find symbol - variable error

    Hi, can you help and fix the code below, i get the error can't find symbol - variable lastName

     
    public class Person
    {
      private String firstName;
      private String lastName;
     
    public Person(String last,String first)
    {
        firstName = first;
        [COLOR="#FF0000"]lastNmae[/COLOR] = last;
    }
    public void setFirstName(String first)
    {
        firstName = first;
    }
    public String getFirstNmae()
    {
        return firstName;
    }
    public void setLastName(String last)
    {
        lastName = last;
    }
    public String getLastNmae()
    {
        return lastName;
    }
    }

    thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: can't find symbol - variable error

    Please psot the full text of the error message that shows the statement where the error is.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: can't find symbol - variable error

    thanks Norm, here is a snapshot of the error
    error.jpg

  4. #4
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: can't find symbol - variable error

    error.jpg

    is it clear pic?

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: can't find symbol - variable error

    Images are no good. Copy the full text of the error message and paste here.
    I can't copy text from an image if I want to use part of it in my response.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: can't find symbol - variable error

    past the below in bluej: will give you compiling error (can't find symbol - variable lastName)

    public class Person
    {
    private String firstName;
    private String lastName;

    public Person(String last,String first)
    {
    firstName = first;
    lastNmae = last;
    }
    public void setFirstName(String first)
    {
    firstName = first;
    }
    public String getFirstNmae()
    {
    return firstName;
    }
    public void setLastName(String last)
    {
    lastName = last;
    }
    public String getLastNmae()
    {
    return lastName;
    }
    }

  7. #7
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: can't find symbol - variable error

    lastNmae = last;

    Spelling mistake in the constructor.

  8. #8
    Junior Member
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: can't find symbol - variable error

    Thank you Chris how i didn't notice this !

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: can't find symbol - variable error

    Why didn't the error message say: lastNmae
    get the error can't find symbol - variable lastName
    That is the problem with NOt copying and pasting from the window where the error message is displayed.
    What the OP typed in was wrong.

    A technique: Select and put into the source code editor's Find window a good version of the string and then do Finds for that string over the rest of the program. When the Find skips over one, then you KNOW that that one is different.

    Another technique is post it here and let one of the volunteers find it for you. Knowing how to solve problems is something a programmer needs to learn.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: can't find symbol - variable error

    Sage advice. OP, there are a few more spelling mistakes in your code. Use Norm's technique to track them down.

Similar Threads

  1. Errod in R.id, cannot find symbol variable id
    By aparnakm in forum Android Development
    Replies: 1
    Last Post: February 9th, 2012, 12:34 AM
  2. Cannot Find Variable/Symbol Errors... why?
    By bgroenks96 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 9th, 2011, 04:12 AM
  3. Help with Cannot Find Symbol Variable errors
    By skboone in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 20th, 2010, 10:52 AM
  4. cannot find symbol variable radius?
    By noobish in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 4th, 2009, 10:29 AM
  5. Replies: 5
    Last Post: September 19th, 2009, 06:48 AM