Skip to content

Instantly share code, notes, and snippets.

@fhanik
Last active April 25, 2018 20:35
Show Gist options
  • Save fhanik/9645aebb79d0a5b50a4e03d51aa12b5c to your computer and use it in GitHub Desktop.
Save fhanik/9645aebb79d0a5b50a4e03d51aa12b5c to your computer and use it in GitHub Desktop.
Java Generics Question
public class A {
public T setSomething() {
return this;
}
}
public class B {
public T setSomethingElse() {
return this;
}
}
public class C {
public T anotherSet() {
return this;
}
}
//I would like this to work
C c = new C()
.setSomething() //returns A
.setSomethingElse() //returns B
.anotherSet(); //returns C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment