java 继承多个接口
2016-03-28 13:01
330 查看
java 继承多个接口
public interface InterfaceA {
int len = 1 ;
void output();
}
public interface InterfaceB {
int len = 2 ;
void output();
}
public interface InterfaceSub extends InterfaceA, InterfaceB { };
public class Xyz implements InterfaceSub {
public void output() {
System.out.println("output in class Xyz.");
}
public void output1(){
System.out.println("output1.");
}
public void output2(){
System.out.println("output2.");
}
public void outputLen(int type) {
switch (type) {
case InterfaceA.len:
System.out.println("len of InterfaceA=." + type);
break;
case InterfaceB.len:
System.out.println("len of InterfaceB=." + type);
break;
}
}
public static void main(String[] args) {
//Xyz xyz= new Xyz ();
Xyz xyz = new Xyz();
xyz.output();
xyz.outputLen(1);
xyz.output1();
xyz.output2();
//System.out.println(len);
}
}
public interface InterfaceA {
int len = 1 ;
void output();
}
public interface InterfaceB {
int len = 2 ;
void output();
}
public interface InterfaceSub extends InterfaceA, InterfaceB { };
public class Xyz implements InterfaceSub {
public void output() {
System.out.println("output in class Xyz.");
}
public void output1(){
System.out.println("output1.");
}
public void output2(){
System.out.println("output2.");
}
public void outputLen(int type) {
switch (type) {
case InterfaceA.len:
System.out.println("len of InterfaceA=." + type);
break;
case InterfaceB.len:
System.out.println("len of InterfaceB=." + type);
break;
}
}
public static void main(String[] args) {
//Xyz xyz= new Xyz ();
Xyz xyz = new Xyz();
xyz.output();
xyz.outputLen(1);
xyz.output1();
xyz.output2();
//System.out.println(len);
}
}
相关文章推荐
- 不用一句java代码就可以实现指示器tabhost,indicator
- struts文件上传和表单校验
- java GBK字符转换成为UTF-8编码字符
- 浅析Java中Map与HashMap,Hashtable,HashSet的区别
- Eclipse配置Maven
- Spring MVC 4常用的那些注解
- java特殊字符转义
- java基础-004
- Java快排
- 交换排序之冒泡排序
- 《Spring Boot实战》笔记 (六章)
- The Java™ Tutorials:Swing
- java【学习笔记(二)】对象导论(1)
- 项目ITP(六) spring4.0 整合 Quartz 实现动态任务调度
- struts2中<s:if>标签的使用
- Spring MVC表单验证
- 防止未登录用户操作—struts2拦截器简单实现
- Struts2自定义拦截器实例—登陆权限验证
- Java Collection Framework概述
- 百家姓转拼音