fork(1) download
  1. import java.util.ArrayList;
  2. import java.util.Arrays;
  3. import java.util.Collection;
  4. import java.util.List;
  5.  
  6. interface Callback<T> {
  7. void call(T t);
  8. }
  9.  
  10. class ConcreteCallback implements Callback<Collection<Object>> {
  11. public void call(final Collection<Object> data) {
  12. for (Object obj: data) {
  13. System.out.println(obj);
  14. }
  15. }
  16. }
  17.  
  18. public class Main {
  19. private static <T, U extends T> void call(final List<U> data, final Callback<? super List<T>> cb) {
  20. ArrayList<T> dat = new ArrayList<>();
  21. for (T object: data) {
  22. dat.add(object);
  23. }
  24. cb.call(dat);
  25. }
  26.  
  27. public static void main(final String[] args) {
  28. call(Arrays.asList(args), new ConcreteCallback());
  29. }
  30. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
Standard output is empty