【黑马程序员】面向对象(三) 第七天

public class InterfaceDemo {public static void main(String[] args) {Test_1 t = new Test_1();System.out.println("t.PI: " + t.PI);//通过Test_1类的引用调用调用从接口继承过来的PI属性值。System.out.println("Test_1.PI: " + Test_1.PI);//通过子类Test_1直接调用从接口继承过来的PI属性值。System.out.println("Inter.PI: " + Inter.PI);//通过接口直接调用PI的属性值。}}interface Inter{//接口public static final double PI = 3.14159;public abstract void show();}class Test_1 implements Inter{//实现接口public void show(){}//实现抽象类}运行结果如下所示:t.PI: 3.14159