using abstract keyword in interface
I know the difference between "public interface" and "public abstract interface", but when applied on methods are there differences?
public interface IPluggableUi {
abstract public JComponent getPanel();
abstract public void initUi();
}
or
public interface IPluggableUi {
public JComponent getPanel();
public void initUi();
}
Solution 1:
Methods declared in interfaces are by default both public and abstract.
Yet, one could:
public interface myInterface{
public abstract void myMethod();
}
However, usage of these modifiers is discouraged. So is the abstract modifier applied to the interface declaration.
Particularly, regarding your question:
"For compatibility with older versions of the Java platform, it is permitted but discouraged, as a matter of style, to redundantly specify the abstract modifier for methods declared in interfaces."
source: http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html
Section 9.4: Abstract method declarations.
Solution 2:
no, you could also write
public interface IPluggableUi {
JComponent getPanel();
void initUi();
}
its the same thing
Solution 3:
A side note: Values defined in an interface are public static final by default so
int VALUE = 5;
is the same as
public static final int VALUE = 5;
in an interface.