You can't instantiate an instance class (CheckingAccount
) from a static method (main
). You have to make the inner class static
:
public abstract class Account {
public static void main(String args[]) {
CheckingAccount Account1 = new CheckingAccount();
}
public Account() {
//
}
public static class CheckingAccount extends Account {
//
}
}
By the way, this is a quite strange design. I would avoid to:
- mix your main method with your classes, just make a new separated Account class instead
- declare an inner class as an extends of the container class, use two classes (in two different classes) instead.