Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@craigotis
Created July 17, 2014 11:36
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 craigotis/135f88b1ce8beca07400 to your computer and use it in GitHub Desktop.
Save craigotis/135f88b1ce8beca07400 to your computer and use it in GitHub Desktop.
public class GenericsTest {
public class Shape {}
public class Circle extends Shape {}
public class Sphere extends Circle {}
public class ShapeDescriber<T extends Shape> {
public void describe(T s) {}
}
public class CircleDescriber<T extends Circle> extends ShapeDescriber<T> {
public void describe(T s) {
super.describe(s);
}
}
public class SphereDescriber<T extends Sphere> extends ShapeDescriber<T> {
public void describe(T s) {
super.describe(s);
}
public void testTheThing() {
this.describe(new Sphere());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment