Problem:
Hi there! I have been learning to program for a long time now and I recently learned inheritance in Java. I wrote the following program for practice:
class Institutions {
public void print_institutions()
{
System.out.println("This is an institution");
}
}
class School extends Institutions{
public void print_school()
{
System.out.println("This is a school");
}
}
class Academy extends School {
public void print_academy()
{
System.out.println("This is an academy");
}
}
class Call{
public static void main(String[] args) {
Institutions institute = new Institutions();
School school = new School();
Academy academy = new Academy();
institute.print_institutions();
school.print_school();
academy.print_academy();
}
}
When I run this program, the compiler throws the following error:
Error - At least one public class is required in main file
I have never seen this type of error before, therefore, I have no idea what is causing this error. Can anybody here please clarify the cause of the error and its solution? Thanks!