fork(1) 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 class GeometryObject {}
  11. public static class Triangle extends GeometryObject {}
  12. public static class Circle extends GeometryObject {}
  13.  
  14. public static <T extends GeometryObject> List<T> getList(Class<T> itemClass) throws Exception {
  15. List<T> res = new ArrayList<T>();
  16. for (int i = 0 ; i != 10 ; i++) {
  17. res.add(itemClass.newInstance());
  18. }
  19. return res;
  20. }
  21.  
  22. public static void main (String[] args) throws java.lang.Exception
  23. {
  24. List<Triangle> triangles = getList(Triangle.class);
  25. List<Circle> circles = getList(Circle.class);
  26. }
  27. }
Success #stdin #stdout 0.07s 381248KB
stdin
Standard input is empty
stdout
Standard output is empty