Skip to content

Instantly share code, notes, and snippets.

@TedaLIEz
Created August 31, 2017 03:29
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 TedaLIEz/ed7e5e12a0ad9c65654fe9e930dd6aa5 to your computer and use it in GitHub Desktop.
Save TedaLIEz/ed7e5e12a0ad9c65654fe9e930dd6aa5 to your computer and use it in GitHub Desktop.
F-bounded style
/**
* If the return type must be the type of the class that implements the interface,
* then what you want is called an F-bounded type
*/
public interface A<T extends A<T>> {
public T b();
}
public class C implements A<C> {
public C b() { ... }
}
public class D implements A<D> {
public D b() { ... }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment