Skip to content

Instantly share code, notes, and snippets.

@smat
Created December 23, 2010 11:31
Show Gist options
  • Save smat/752854 to your computer and use it in GitHub Desktop.
Save smat/752854 to your computer and use it in GitHub Desktop.
class A<E extends A> {
private String name;
E withName(String name) {
this.name = name;
return (E) this;
}
}
class B extends A<B> {
private String job;
B withJob(String job) {
this.job = job;
return this;
}
}
class Main {
public static void main(String[] args) {
new B().withName("Stian").withJob("Konsulent");
new B().withJob("Konsulent").withName("Stian");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment