Please enable JavaScript.
Coggle requires JavaScript to display documents.
Generics (Restrictions on Generics (Cannot create static fields whos types…
Generics
-
Generic Interfaces
public interface Shippable<T> { void ship(T t)}
There are 3 ways how class can approach implementing this interface
-
Don`t use Generics at all
class ShippableCrate implements Shippable{
public void ship(Object o)}
Compiler will warn you that Shippable being a raw type, but it does compile
Specify generic type in the class
class ShippableRobotCrate implements Shippable<Robot> {
public void ship (Robot t){}}
-