Skip to content

Instantly share code, notes, and snippets.

@bradhe
Created June 24, 2012 05:33
Show Gist options
  • Select an option

  • Save bradhe/2981802 to your computer and use it in GitHub Desktop.

Select an option

Save bradhe/2981802 to your computer and use it in GitHub Desktop.
Is this even possible in Java??
public <T> MyList ofType(Class<T> klass) {
MyList list = new MyList();
for(MyElement elem : this) {
if(elem instanceof klass) {
list.add(elem);
}
}
return(list);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment