The interface can contain variables and methods. However, the variables in the interface are implicitly specified as public static final variables (and can only be public static final variables, which are reported as compilation errors with private adornments), and methods are implicitly specified as public Abstract method and can only be public abstract method (with other keywords, such as private, protected, static, final and so on will be reported compile errors), and the interface of all methods can not have a concrete implementation, that is to say, The methods in the interface must all be abstract methods.
These are all well-known, but what I want to say is:
The invocation of the package allows the abstract methods in the interface to be used directly, such as the methods in the iterator interface, which can be called directly
Collection C1 = new ArrayList ();
C1.add ("123");
C1.add ("456");
C1.add ("789");
Iterator it = C1.iterator ();
while (It.hasnext ();)
System.out.println (It.next ());
This emphasis is placed on the invocation of the package.
Methods in the Java interface