You can achieve the required behaviour in two ways :
First :
abstract class A {
void method1();
void method2();
void method3 () {
//default implmentation or empty body
}
}
class B extends A {
@override
method1() {}
@override
method2() {}
}
Second :
abstract class A {
void method1();
void method2();
}
abstract class A1 extends A {
void method3();
}
class B extends A1 {
@override
method1() {}
@override
method2() {}
}
This way you only get warning when you're class extends A1
class without implementing method3()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…