fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. List<Bar> list = new ArrayList<Bar>();
  13. list.add(new Bar());
  14. Ideone.hoge(list);
  15. }
  16.  
  17. static <T extends Foo> void hoge(List<T> list) {
  18. list.get(0).p();
  19. }
  20.  
  21. static interface Foo {
  22. void p();
  23. }
  24. static class Bar implements Foo {
  25. public Bar() {}
  26. @Override
  27. public void p() { System.out.println("p"); }
  28. }
  29.  
  30.  
  31.  
  32.  
  33. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
p