Skip to content

Instantly share code, notes, and snippets.

@fredlahde
Created July 24, 2016 14:48
Show Gist options
  • Save fredlahde/6d024c29fee700566e65f05397b48426 to your computer and use it in GitHub Desktop.
Save fredlahde/6d024c29fee700566e65f05397b48426 to your computer and use it in GitHub Desktop.
import java.util.Collection;
import java.util.HashSet;
class TestKlasse {
public TestKlasse() {
}
}
interface Buildable<T> {
void build(int x, Collection<T> c);
}
interface Destroyable<T> {
void destroy(T x);
}
public class FancyStuff {
public static void main(String[] args) {
Buildable b = (Buildable<TestKlasse>) (count, c) -> {
for (int i = 0; i < count; i++) {
c.add(new TestKlasse());
}
};
Destroyable destroyer = (Destroyable<TestKlasse>) (testKlasse)
-> System.out.println(testKlasse + "is kapuut jetzt");
Collection set = new HashSet();
b.build(20, set);
set.forEach(destroyer::destroy);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment