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

后端 未结 13 426
清酒与你
清酒与你 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:43

    What List are you importing? (see this thread from 2006)

    java.awt.List or java.util.List?

    Because, as eclipse aptly comments, java.awt.List is not parameterized ;)


    Check also the

    • Java Build path: it must not contain a reference to the J2SE 1.4.2 libraries.
    • Source Compatibility: project properties -> Java Compiler Settings, Source Compatibility 5.0 or 6.0.

    Other than that, there was lots of issue back in 2005 when the latest Eclipse 3.1 beta was supporting J2SE5, but this was fixed since then.

    Try tyo use the latest JDK6 in your project.

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

    make java buildpath reference to greater than or equal to java 1.5

    or you try to add the "import java.util.List" statement then you can see that

    eclipse is saying it is conflicting with some other List type

    for example it may be conflicting with com.lowagie.xx.xxx.List etc try to avoid these import

    statements

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

    It's late but still replying, might be helpful for others who are still facing the issue. I was getting exactly the same issue. The List was proper with util.List. The solution was to order the exports of the libraries. If you are using Maven or any other Libraries :

    In Project -> Build Path -> Configure Build Path -> Order & Exports

    Check 'JRE System Libraries' should be above 'Maven Dependencies'

    This worked for me.

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

    Hey, I removed the cryptic library and it didn't work. But then I put JRE System Library at the top, and it worked. Really weird.

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

    Did you name your class list? i.e:

    import java.util.*;
    
    public class List {   // can't do this, name this something else.
    
        public static void main(String[] args) {
            List<Integer> l = new ArrayList<Integer>();
    
        }
    
    }
    
    0 讨论(0)
  • 2020-12-05 03:51

    Some ideas:

    • check the JRE library being used in your project (check the package explorer).
    • check the installed JREs in the eclipse settings (same as used by ant).
    • comment out the line just to check if it really is the error cause.
    • retype the whole line from scratch.
    • install a new (clean) version of eclipse, in a new folder (testing).
    0 讨论(0)
提交回复
热议问题