· An interface must be declared with the keyword interface
· Interfaces are by default abstract
i.e.:
public interface Comparable
is the same as:
public abstract interface Comparable
· All methods are by default public abstract although it does not have to be mentioned. So, notice the following declarations are equal:
public void method();
public abstract void method();
Because interface methods are abstract, they cannot be marked final, strictfp, native and private.
e.g. private void method() is incorrect.
· All variables are public static final by default
pubic int x = 3;
is the same as:
public final static int x = 3;
Because variables are final you have to declare and initialize them, you can’t have in the
interface something like this:
pubic int x;
Brak komentarzy:
Prześlij komentarz