Internal class instances of members of the Java inner class

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.