棟兄はあなたを連れてJavaインタフェースを学びます
3839 ワード
Javaのインタフェース
?
.
?
java , , . java , .
:
:
:interface
?
interface {
}
:
:
interface InterA {
public static final int num = 10;
int num1 = 10;
public abstract void fun();
}
: jdk1.8 , , , abstract, . , . public static final, , . implements, , .
? , , .
, , extends.
interface InterB{
public abstract void fun();
}
interface InterC{
public abstract void test();
}
interface InterDe extends InterB,InterC{
}
class Test implements InterB,InterC {
@Override
public void fun() {
// TODO Auto-generated method stub
}
@Override
public void test() {
// TODO Auto-generated method stub
}
}
, .
JDK1.8 :
, .
:
interface InterX {
//
public abstract void print();
//
public static void staticFun() {
System.out.println(" staticFun()");
}
// ( default )
public default void defaultFun() {
System.out.println(" defaultFun()");
}
}
, , . , , ,