今天学了什么
利用接口达到了多继承的效果
TestIFA接口:
package mex;
public interface TestIFA {
int a=1;
int b=2;
int c=3;
void printInfo();
}
TestIFB接口:
package mex;
public interface TestIFB {
int d=4;
int e=5;
int f=6;
void printInfo();
}
IFDemo类:
package mex;
public class IFDemo implements TestIFA,TestIFB {
@Override
public void printInfo() {
System.out.println("Info");
}
public static void main(String[] args) {
IFDemo d=new IFDemo();
d.printInfo();
System.out.println(d.a);
System.out.println(d.b);
System.out.println(d.c);
System.out.println(d.d);
System.out.println(d.e);
System.out.println(d.f);
}
}
运行截图:
明天计划
学习第八章 程序的异常