Current location - Trademark Inquiry Complete Network - Futures platform - There are the same methods in the java interface and the parent class. How to override methods in interfaces in subclasses?
There are the same methods in the java interface and the parent class. How to override methods in interfaces in subclasses?
Override the method of the parent class and override the method of the interface. Two methods are equivalent to one method.

One method is to override a method for which method of the parent class and call super, as shown below:

The public class Aaa extends B and realizes A {

Public void a() {

System. Out.println ("method of interface");

}

Public void extension A(){

super . a();

}

Public static void main(String[] args) {

Aaa Aaa = new Aaa();

AAA . a(); //Implement the method in the interface.

AAA . extendsa(); //This is the function of the parent method itself, so be careful when calling.

}

}

Interface A {

void a();

}

Class b {

Public void a(){

system . out . println(" b ");

}

}