Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Have created a superclass and made another class for testing but i get this error code, kindly help :p just newbie :(

public class Building {

private String address;

public Building(String add)     {

    address = add;
}   

public String getAddress() {

    return address;
}   

public void getDescription()    {

    System.out.println(address + "is a building");
}   

public class House extends Building {

    public House (String add) {
        super(add);
    }   

    public void getDescription()    {

        System.out.println(super.getAddress() +" is a House"); 
    }

}

public class School extends Building {

    public School (String add) {

        super(add);
    }   

    public void getDescription()    {

        System.out.println(super.getAddress() +" is a School");
    }

}

}


//Test the buildings

public class TestBuildings {

public static void main(String[] args) {

    School b1 = new School ("West Mackay");

    b1.getDescription();                
}

}

error i am getting when i am running my TestBuildings "error: cannot find symbol School b1 = School("West Mackay");

2 Answers

Hmm I copied your code, placing all classes in the same package, and did not get that error. Some times that error arises when there is a missing import statement. This stackoverflow response also lists some of the other common reasons: https://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-compilation-error-mean#25706217

Hi lebowski,

thanks for the reply :p will check out the link you provided,

thanks