interfaces
11 tutorials tagged “interfaces”.
- Functional Interfaces in JavaA functional interface has exactly one abstract method and can be implemented with a lambda. Learn the rules, @FunctionalInterface, and how to write your own.
- Difference Between Abstract Class and InterfaceAbstract class or interface? A full comparison, how to choose, and the skeletal-implementation pattern that uses both, the way the JDK does.
- Difference Between Class and InterfaceA class is a complete blueprint for objects; an interface is a contract. Compare what each can contain, create and inherit, with one example using both.
- Diamond Problem with Default MethodsWhen a class inherits the same method from a class and interfaces: the three resolution rules, each shown running, plus the compile errors.
- The Diamond ProblemWhy Java has no multiple inheritance of classes: the diamond problem, clashing interface default methods, and resolving them explicitly.
- Generic Interfaces in JavaInterfaces with type parameters: a Repository<T, ID> contract, implementing it with real types or keeping it generic, and the JDK's Comparable<T>.
- Default, Static and Private Methods in InterfacesInterfaces with code: default methods that let interfaces grow, static helpers called on the interface, and private methods that share code inside it.
- Interfaces in JavaAn interface is a contract any class can sign: declaring and implementing one, implicit public abstract methods, constants, and interfaces as types.
- Marker Interfaces in JavaEmpty interfaces that tag a class: Serializable, Cloneable and RandomAccess, writing your own marker, and when an annotation is the better choice.
- Multiple Inheritance Through InterfacesA class can implement many interfaces and an interface can extend many: how Java gets multiple inheritance of type without the diamond problem.