Interface interface in java distinction, php

php:

Specification: 
    Interface is a special abstract class, an abstract class that contains only static constants and abstract methods. 
    Abstract method in the interface can only be public, the default is public access. 
    abstract and final modifiers can not abstract methods interface modification. 

interface the User 
{ 
    // public $ name; // error, can only contain abstract methods and static constants. 
    const the GROUP = 12 is; // static constant 

    // public function t () {} ; // error, comprising only static constants and abstract methods. 
    // private function t () {} ; // error, only an abstract interface methods are public, but also public default permissions. 
    // abstract function t () {} ; // given, abstract and final modifier is not an abstract method interface modification. 

    // only the following two methods can define 
    public  function RIGHT1 ();
     function RIGHT2 (); 
}

java:

public  interface Interface name {
     // abstract methods: using the abstract modification keyword may be omitted, there is no method thereof. The method used for sub-class implementation. 
    public  abstract  void Method (); 

    // default method: modified using the default, not be omitted for the call subclass or the subclass
     @ static methods: using static modification, the interface for direct 
    public  default  void Method () {
         // execute statement 
    } 
// only through the interface name calling, can not be achieved by calling the class
public static void method2 () { // execute statements } // private method: using private modification, the default method for the interface or static method call. Private void Method () { // execute statement } } Class implements the interface class name of the class implements the interface name { // interface abstract methods must override [] // interface override the default method [optional] }

 

Guess you like

Origin www.cnblogs.com/qq1069284034/p/11654213.html