Java Interface and Class Hierarchy
来源:互联网 发布:nhj软件 编辑:程序博客网 时间:2024/05/22 08:56
public interface IClassUpA {
?? ?public void sayA();
}
public interface IClassUpB {
??? public void sayB();
}
public interface IClassUp extends IClassUpA, IClassUpB {
??? public void say();
}
// Do NOT implements IClassUpA here!
public class ClassUpA {
??? public void sayA() {
??? ??? System.out.println("ClassUpA sayA()");
??? }
}
// Here ClassUp implements IClassUp, which extends IClassUpA and IClassUpB.
//
// Now the ClassUp's method sayA(), which extended by ClassUpA, is the
// implementation of IClassUpA#sayA().
//
// That is to say, even though ClassUpA.sayA() is not the implementation of
// IClassUpA.sayA, it becomes the implementation of IClassUpA.sayA() by its
// descendant class ClassUp through "extends ClassUpA implements IClassUp".
//
// Something interesting and somewhat confusing for some large system.
public class ClassUp extends ClassUpA implements IClassUp {
??? // No need to implement the IClassUpA.sayA() here!
??? public void say() {
??? ??? System.out.println("ClassUp say()");
??? }
??? public void sayB() {
??? ??? System.out.println("ClassUp sayB()");
??? }
}
// Test my idea.
public class InterfaceAndClassTest {
??? public static void main(String[] args) {
??? ??? Object cu = new ClassUp();
??? ??? if (cu instanceof ClassUpA) {
??? ??? ??? ClassUpA myCU = (ClassUpA) cu;
??? ??? ??? myCU.sayA();
??? ??? }
??? }
}
// Result:
// ClassUpA sayA()
// Copyright NOTICE:
// You are authorized to copy and use this example codes and comments for
// non-commercial use, under the condition that you keep? the article's copyright
// notice unchanged and ship with the notice.
// This article is firstly posted at
// http://blog.csdn.net/reve/
/*******************************************************************************
?* Copyright (c) 2002, 2004 IDSignet.
?* All rights reserved.
?* http://www.idsignet.com
?*
?* Created on Jul 6, 2004
?*******************************************************************************/
/**
?* @author Janyckee Joz
?*/
?? ?public void sayA();
}
public interface IClassUpB {
??? public void sayB();
}
public interface IClassUp extends IClassUpA, IClassUpB {
??? public void say();
}
// Do NOT implements IClassUpA here!
public class ClassUpA {
??? public void sayA() {
??? ??? System.out.println("ClassUpA sayA()");
??? }
}
// Here ClassUp implements IClassUp, which extends IClassUpA and IClassUpB.
//
// Now the ClassUp's method sayA(), which extended by ClassUpA, is the
// implementation of IClassUpA#sayA().
//
// That is to say, even though ClassUpA.sayA() is not the implementation of
// IClassUpA.sayA, it becomes the implementation of IClassUpA.sayA() by its
// descendant class ClassUp through "extends ClassUpA implements IClassUp".
//
// Something interesting and somewhat confusing for some large system.
public class ClassUp extends ClassUpA implements IClassUp {
??? // No need to implement the IClassUpA.sayA() here!
??? public void say() {
??? ??? System.out.println("ClassUp say()");
??? }
??? public void sayB() {
??? ??? System.out.println("ClassUp sayB()");
??? }
}
// Test my idea.
public class InterfaceAndClassTest {
??? public static void main(String[] args) {
??? ??? Object cu = new ClassUp();
??? ??? if (cu instanceof ClassUpA) {
??? ??? ??? ClassUpA myCU = (ClassUpA) cu;
??? ??? ??? myCU.sayA();
??? ??? }
??? }
}
// Result:
// ClassUpA sayA()
// Copyright NOTICE:
// You are authorized to copy and use this example codes and comments for
// non-commercial use, under the condition that you keep? the article's copyright
// notice unchanged and ship with the notice.
// This article is firstly posted at
// http://blog.csdn.net/reve/
/*******************************************************************************
?* Copyright (c) 2002, 2004 IDSignet.
?* All rights reserved.
?* http://www.idsignet.com
?*
?* Created on Jul 6, 2004
?*******************************************************************************/
/**
?* @author Janyckee Joz
?*/
- Java Interface and Class Hierarchy
- The Interface and Class Hierarchy Diagram of Java Collections
- effective java -Class and Interface
- java interface and abstract class
- Java-Abstract Class and Interface
- Java - Difference between Abstract class and Interface
- interface and abstract class in java
- Java AWT Class Hierarchy
- [Scarab] Structure and Class Hierarchy
- java中看class,interface之间的extends,implements的关系,,用F4,open type hierarchy
- class and interface
- Interface And Abstract Class
- Interface and abstract class
- Abstract class and Interface
- Abstract Class And Interface
- interface and abstract class
- Trivial_1_abstract class and interface
- Abstract class and interface
- 编写服务器控件时,向页面写入脚本的方法
- 保安凭什么查看公民身份证
- ping finger nslookup netstat
- 3D进度条控件(Dephi)
- 字体下拉列表框(Dephi)
- Java Interface and Class Hierarchy
- 状态条控件(Dephi)
- 用C#实现生成PDF文档(原码)
- 自定义消息的处理
- 程序自杀控件(Dephi)
- 数据日历控件(Dephi)
- Linux下的打印工作命令
- 数据日期选择控件(Dephi)
- 与系统管理有关的命令