Skip to content

Instantly share code, notes, and snippets.

@stefanobaghino
Created February 16, 2018 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanobaghino/fb4a54844e038369a2105bd3d8504ef3 to your computer and use it in GitHub Desktop.
Save stefanobaghino/fb4a54844e038369a2105bd3d8504ef3 to your computer and use it in GitHub Desktop.
public interface Animal {
String salutation();
}
public final class Cage<T> {
public final T value;
public Cage(T value) {
this.value = value;
}
}
public final class Dog implements Animal {
@Override
public String salutation() {
return "bark";
}
public static void main(String[] args) {
Cage<? extends Animal> cage = new Cage(new Dog());
System.out.println(cage.value.salutation());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment