健全党和国家监督体系的创制之举
?????(interface)? ?? ????? ???? ????? ???? ?? ??? ????? ???? ?? ?????. ??? ????? ????. ?????? interface
?? ???? ???? ????, ??? ????? ?? ??(static? final? ? ? ???? ?? ??)?? ??? ? ??. ?? 8 ??? ?? ??? ???? ?????? ?? ???? ???(??? ??)? ???? ?? ??. ?? 8??, default
? static
???? interface
??? ???? ??? ?? ? ??.[1]
???
[??]????? ??
[??]??????? ??? ??? ???? ????.
[visibility] interface InterfaceName [extends other interfaces] { constant declarations abstract method declarations }
?: public interface Interface1 extends Interface2;
?????? ??(body)? ?? ???? ???? ??? ????? ?? ?? ????? ??? ????? ??? abstract
???? ???? ??. ?????? ??? ???? ??? ????? ?? ????? ????? public
??.
???? ??? ?????? ??? ?? ? ? ??.
public interface Predator {
boolean chasePrey(Prey p);
void eatPrey(Prey p);
}
?????? ????? ??
[??]????? ?? ??? ?? ??? ????:
... implements InterfaceName[, another interface, another, ...] ...
???? ?????? ??? ? ??. ???? ??? ??.
public class Lion implements Predator {
@Override
public boolean chasePrey(Prey p) {
// programming to chase prey p (specifically for a lion)
}
@Override
public void eatPrey(Prey p) {
// programming to eat prey p (specifically for a lion)
}
}
???? ?????? ????? ???? ?? ???? ????, abstract
? ????? ??. ???? ?????? ?????? ? ??? ??? ???? ??? ??? ????. ?? ???? ?????? ? ?? ?? ????? ???? ?? ???? ???? ????? ??? abstract
? ?? ????? ??.
????? ?? ??????? ??? ? ??.
public class Frog implements Predator, Prey { ... }
??????? ????? ??? ???? ?? ???? ????.[2] ??? ???(????)? ??(argument)? ???? ?? ???? ???.
???????
[??]??????? ??? ?? ?? ??? ???? ?? ?? ??????? ??(extend)? ? ??. ????, ???
public interface VenomousPredator extends Predator, Venomous {
//interface body
}
??? ???? ???????? ????.
?? ??
[??]??
[??]- ↑ “Default Methods”. 2017? 5? 23?? ?? ???? ??? ??. 2017? 4? 27?? ???.
- ↑ “Java World”. 2008? 9? 16?? ?? ???? ??? ??. 2017? 3? 28?? ???.