Below is my code. I am not getting what is the mistake. Can anyone be able to guide.
class State {
static String country;
static String capital;
Sta
class State
{
static String country;
static String capital;
State() //Constructor
{
country = "America's";
capital = "Washington D.C";
}
static void display()
{
System.out.println(capital + " " + "is" + " " + country + " " +"capital." );
}
}
Main class
class Place extends State // Inheritance
static void display()
{
System.out.println("Capital is Washington D.C.");
}
public static void main(String[] args)
{
State st = new State();
st.display(); // to print sub class method
display(); // to print same class method
//st = pl; No idea of this point ..
}
}
Your Place
class needs to be defined as public
.
Edit: The file also must be named Place.java