标签:
* 接口(interface)
1 public class TestInterface { 2 public static void main(String[] args) { 3 System.out.println(AA.I); 4 // AA.I = 13; 5 } 6 } 7 8 interface AA{ 9 //常量:所有的常量都用public static final修饰 10 int I = 12; 11 boolean FLAG = false; 12 // int i; 13 //抽象方法:所有的都用public abstract修饰 14 void method1(); 15 void method2(); 16 } 17 18 abstract class BB implements AA{ 19 20 } 21 class DD{ 22 23 } 24 interface MM{ 25 void method3(); 26 } 27 class CC extends DD implements AA,MM{ 28 public void method1(){ 29 30 } 31 public void method2(){ 32 33 } 34 public void method3(){ 35 36 } 37 } 38 //接口之间仍为继承关系!(多继承) 39 interface JJ extends MM,AA{ 40 void method4(); 41 } 42 43 class GG implements JJ{ 44 45 @Override 46 public void method3() { 47 // TODO Auto-generated method stub 48 49 } 50 51 @Override 52 public void method4() { 53 // TODO Auto-generated method stub 54 55 } 56 57 @Override 58 public void method1() { 59 // TODO Auto-generated method stub 60 61 } 62 63 @Override 64 public void method2() { 65 // TODO Auto-generated method stub 66 67 } 68 69 }
标签:
原文地址:http://www.cnblogs.com/zhangfan94/p/4263298.html