Classes declared with the abstract keyword become "abstract classes". An abstract method is an incomplete method in which only one declaration has no body part of the method.
1 Public Abstract classAbstracttest {2 3 //Abstract Methods4 Public Abstract voidtest1 ();5 6 //Non-abstract methods7 Public voidtest2 () {8SYSTEM.OUT.PRINTLN ("Non-abstract method in abstract class");9 }Ten One}
The above code explains that abstract classes are incomplete classes, and the methods are not fully implemented.
And look at the code below.
1 Public classAbstractextendsextendsAbstracttest {2 3 @Override4 Public voidtest1 () {5 //TODO auto-generated Method Stub6 7 }8 9 Public Static voidMain (string[] args) {TenAbstracttest abstracttest =Newabstracttest () { One A @Override - Public voidtest1 () { - //TODO auto-generated Method Stub the - } - }; - } +}
Attention:
1. Abstract classes cannot be instantiated directly,
2. When inheriting an abstract class, you need to override each abstract method in the class.
Java abstract class