These are Interfaces defined for Java. They act like public facing APIs. They are similar to Java Abstract Class, but they:
- Cannot have any Concrete Methods
- Can have Java Default Methods
- The only attributes allowed must be
final staticattributes (attributes are not well supported)
Implementing a Interface
class myClass implements myInterface{
// ...
}Boilerplate
interface Animal {
public static int mytag;
public void animalSound(); // interface method (does not have a body)
public void run(); // interface method (does not have a body)
public default void die(){
System.out.println("poof");
}
}