The first is how to implement simultaneous inheritance of two classes
public class Multiextendsdemo {public static void main (string[] args) {//TODO auto-generated method STUBC c = new C (); C.s Howa (); C.showb ();}} Also inherit two classes class A{public void ShowA () {System.out.println ("A");}} Class B{public void ShowA () {System.out.println ("B");}} Class C{private class C1 extends A{public void ShowA () {Super.showa ();}} Private class C2 extends B{public void ShowA () {Super.showa ();}} public void ShowA () {new C1 (). ShowA ();;} public void Showb () {new C2 (). ShowA ();;}
The second is how to inherit if a class and interface have a method of the same name
What happens to the same method name in the public class MultiExtendsDemo2 {//Inheriting classes and interfaces? public static void Main (string[] args) {//TODO auto-generated method Stubson son = new son (); Son.show (); Son.show2 ();}} Abstract class Parent{abstract public void Show (); Interface ishow{void Show ();} /*class Son extends Parent implements ishow{//One method is to change the name, change the interface to Show1public Void Show () {}public void Show1 () {}}*/class Son Extends Parent{public void Show () {System.out.println ("Show method in abstract class");} Private class Sonson implements Ishow{public void Show () {System.out.println ("Show method in Interface");}} public void Show2 () {new Sonson (). Show ();}}
Internal class instances of members of the Java inner class