fork download
  1. import java.util.*;
  2.  
  3. class Test{
  4. interface Visitor{
  5. public <T> void visit(T Value);
  6. }
  7.  
  8. class MyVisitor<T> implements Visitor{
  9. List<T> list = new ArrayList<T>();
  10.  
  11. public <T> void visit(T value){
  12. list.add(value);
  13. }
  14.  
  15. }
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:12: error: no suitable method found for add(T#1)
            list.add(value);
                ^
    method List.add(int,T#2) is not applicable
      (actual and formal argument lists differ in length)
    method List.add(T#2) is not applicable
      (actual argument T#1 cannot be converted to T#2 by method invocation conversion)
  where T#1,T#2 are type-variables:
    T#1 extends Object declared in method <T#1>visit(T#1)
    T#2 extends Object declared in class Test.MyVisitor
1 error
stdout
Standard output is empty