Interface A:
package snippet;
public interface IAPaint {
public void paint();
}
Interface B:
package snippet;
public interface IBPaint {
public void paint();
}
这样实现就可以了:
package snippet;
public class ABImpl implements IAPaint, IBPaint {
public void paint() {
System.out.println("Paint");
}
public static void main(String[] args) {
IAPaint implA = new ABImpl();
implA.paint();
IBPaint implB = new ABImpl();
implB.paint();
}
}
实现了以后,A和B接口实现共享同个方法体。
呵呵,c#可以这样:
public class SampleClass : IControl, ISurface
{
void IControl.Paint()
{
System.Console.WriteLine("IControl.Paint");
}
void ISurface.Paint()
{
System.Console.WriteLine("ISurface.Paint");
}
}
分享到:
相关推荐
在多个以太网口的电脑上,使用SharpPcap来抓包的时候需要选择网口,但是SharpPcap里面的网口名字和微软系统里面的网口名字又不相同,“控制面板\网络和 Internet\网络连接”里面的网口名字可以通过NetworkInterface...
Java中的interface接口
C# interface学习经验浅谈
C++的多重继承功能较广,Java的interface功能只是其中的一个子集。因为C++的虚拟函数可以有纯虚拟函数,也可有非纯虚拟函数,而Java只有抽象函数,所以功能模式少一种,自然能达到的效果较少一些。 但这并不代表Java...
Java Native Interface Specification release 1.1 pdf版
THIS book covers the Java™ Native Interface (JNI). It will be useful to you if you are interested in any of the following: • integrating a Java application with legacy code written in languages such...
Java中interface接口的作用
Visual C# Custom Interface VS2008 Example
JNI(java native interface) 简体中文:do.chuan@gmail.com 翻译版 英文版:Addison.Wesley.Java.Native Interface 希望对大家有帮助...
另外我发现论坛上学习Java的人都非常的有个性,当有人问起学习哪种语言更好时,他会打出几百个“JAVA”来,填满整个屏幕,也不说是为了什么。我觉得这样做未免有些太霸道了,如果你说这叫偏执狂我也不反对,虽然我...
THIS book covers the Java™ Native Interface (JNI). It will be useful to you if you are interested in any of the following: • integrating a Java application with legacy code written in languages such...
Java Native Interface 必看资料
Interface接口的定义和用法 马克-to-win Java视频的详细介绍
FANUC Robot Interface (FRRJIF.DLL) is Windows software module to read/write robot data with robot over Ethernet. FANUC机械手接口(FRRJIF.DLL)是Windows软件模块,用于通过以太网通过机械手读取/写入机械手...
C#接口(Interface)用法分析.pdf
详解java接口interface
abstract class和interface是Java语言中对于抽象类定义进行支持的两种机制,正是由于这两种机制的存在,才赋予了Java强大的面向对象能力。abstract class和interface之间在对于抽象类定义的支持方面具有很大的相似性...
Java Native Interface Specification-JDK1.6,内有一些实例代码,
java用 @interface Annotation{ } 定义一个注解 @Annotation,一个注解是一个类。 @Override,@Deprecated,@SuppressWarnings为常见的3个注解。 注解相当于一种标记,在程序中加上了注解就等于为程序加上了某种标记...
JNI调用的参考文档, 做java本地调用的时候必备的参考手册 官方电子书 PDF 版, 虽然不如线上文件新, 但是电子书文字排版非常清晰易读, 有收藏价值.