The type Collection is not generic; it cannot be parameterized with arguments <? extends E>

后端 未结 13 424
清酒与你
清酒与你 2020-12-05 03:02

I have a strange problem with Eclipse Galileo.
I set Java 1.6 as my JRE. On this line of code

List templates = new ArrayList ();

I see

相关标签:
13条回答
  • 2020-12-05 03:31

    Try to remove import antlr.collections.List; and click Ctr+space to use java.util

    0 讨论(0)
  • 2020-12-05 03:32

    I changed the import

       import javax.swing.text.html.HTMLDocument.Iterator;
    

    to

       import java.util.Iterator;
    

    then it worked for me

    0 讨论(0)
  • 2020-12-05 03:33

    put the entry "JRE System Library..." at the top in project, properties, java build path, order and export

    0 讨论(0)
  • 2020-12-05 03:34

    For those, who will get there from Google: the problem was with cryptix library. When I removed it from java build path the project is compiled sucesfully.

    0 讨论(0)
  • 2020-12-05 03:34

    use "import java.util.List"

    instead of default import "import antlr.collections.List;"

    and use the JRE5 or above for generic support of collection API....

    0 讨论(0)
  • 2020-12-05 03:40

    for example:

    public class AClass<T extends Object>
    {
     public HashMap<String, String> myMap;
    }
    

    if I write:

    public class BClass
    {
    
    private AClass aClass = new AClass();
    
    public void test()
    {
    
    aClass.get("test");
    //return Object class
    
    }
    
    }
    

    but if I write:

    public class BClass
    {
    
    private AClass<?,?> aClass = new AClass<?,?>();
    
    public void test()
    {
    
    aClass.get("test");
    //return String class
    
    }
    
    }
    
    0 讨论(0)
提交回复
热议问题