Created
December 23, 2010 11:31
-
-
Save smat/752854 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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