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: Problems with Inheritance

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

    Default Problems with Inheritance

    I was experimenting with inheritance, trying to write an example for myself from scratch. For testing purposes, I wanted my child class to print something from my parent class, but what I get is "cannot find symbol" in my IDE. What am I doing wrong?



    Parent class:

     
    package Human;
     
    public class Human {
        private String Skin;
     
     
    public Human() {
    Skin = "Orange";
    }
     
    public Human(String xSkin) {
    Skin=xSkin;
    }
     
    public void setSkin(){
        this.Skin= Skin;
    }
    public String getSkin(){
        return Skin;
    }
    public String toString() {
        return Skin;
    }
    }

    Child class:

     
     
    package Human;
     
     
    public class Legs extends Human {
     
        public Legs() {
            super();
     
        }
        public Legs(int legs) {
           legs = 2;
     
        }
        public Legs (Human h){
         super(h.getSkin());
        }
    System.out.println(super.getSkin());
     
     
    }


  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: Problems with Inheritance

    cannot find symbol
    Please copy the full text of the error message and paste it here. It has important info about the error.
    What symbol and on what line?
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: Problems with Inheritance

    "cannot find symbol
    symbol: class out
    location: class System

    <identifier> expected

    illegal start of type "

  4. #4
    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: Problems with Inheritance

    What source line is the error on? Post the source line where the error happened.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Nov 2013
    Posts
    20
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: Problems with Inheritance

    Thanks mate. It's getting a bit clearer now

Similar Threads

  1. Inheritance[HELP!]
    By cjasonpogi in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 22nd, 2013, 02:56 AM
  2. Inheritance
    By vasanthjayaraman in forum Java Theory & Questions
    Replies: 5
    Last Post: July 10th, 2013, 12:28 PM
  3. Problems with understanding inheritance/method overiding
    By Jackbruns28 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 26th, 2013, 08:50 PM
  4. Inheritance problems
    By 93tomh in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 15th, 2012, 06:01 AM
  5. inheritance
    By b109 in forum Java Theory & Questions
    Replies: 3
    Last Post: May 30th, 2010, 09:23 PM