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

Thread: cannot find symbol - method

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    13
    My Mood
    Confused
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default cannot find symbol - method

    Hi,
    I hope someone help me with the problem I'm having. I am trying write a method which move the x position of an object by a required amount. The object(s) are subclasses which combine on screen to make a picture.
    I'm trying to call the methods from the superclass but each time I try I get the error


    I'm trying to get the method to return the value from getpox which can then be used by the setpox method after the integer from increase has been added.

    Can anyone help me understand what I'm doing wrong, hopefully if I know why it won't work I can figure out what I need to do.

    Thanks.
    Last edited by kyuss; December 7th, 2009 at 05:00 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,267
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: cannot find symbol - method

    I'm unclear where getXPos is defined based upon the description, but a few guesses: if the getXPos method is defined in the superclass, make sure the classes you are calling getXPos extends the superclass where this behavior is defined. If you are trying to call getXPos in the superclass but that method is defined in a subclass, you cannot do it this way.

     
    public class A{
        //you don't have access to getXPos
    }
    public class B extends A{
        public int getXPos(){
            return this.xPos;
        }
        //you have access to getXPos
    }
    public class C extends B{
        ///you have access to getXPos
    }

  3. The Following User Says Thank You to copeg For This Useful Post:

    kyuss (December 7th, 2009)

  4. #3
    Junior Member
    Join Date
    Dec 2009
    Posts
    13
    My Mood
    Confused
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: cannot find symbol - method

    If you are trying to call getXPos in the superclass but that method is defined in a subclass, you cannot do it this way.
    Thanks, that is indeed what I was trying to do

Similar Threads

  1. Need help with program please: getting symbol error
    By blinkzz in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: November 18th, 2009, 01:23 AM
  2. Replies: 2
    Last Post: November 3rd, 2009, 05:28 AM
  3. 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
  4. Replies: 5
    Last Post: September 19th, 2009, 06:48 AM
  5. [SOLVED] How to a set java class path?
    By captjade in forum Java Theory & Questions
    Replies: 1
    Last Post: March 10th, 2009, 06:40 AM