fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. public class Main
  6. {
  7. public static <T> void myFill(List<T> list, T elem) {
  8. Collections.fill(list, elem);
  9. }
  10. public static void main (String[] args)
  11. {
  12. Foo<Integer> obj = new Foo<>(1);
  13. List<Number> l = new ArrayList<>();
  14. obj.fillIntoList(l);
  15. }
  16. }
  17.  
  18. class Foo<T> {
  19. private T elem;
  20. public Foo(T elem) {
  21. this.elem = elem;
  22. }
  23.  
  24. private T get() {
  25. return elem;
  26. }
  27.  
  28. public void fillIntoList(List<? super T> list) {
  29. T currentValue = get();
  30. Main.myFill(list, currentValue);
  31. }
  32. }
Success #stdin #stdout 0.08s 46636KB
stdin
Standard input is empty
stdout
Standard output is empty