What does “The type ArrayList is not generic” mean?

前端 未结 3 1871
猫巷女王i
猫巷女王i 2020-12-06 19:36

I am new to Java and trying to learn the various collections that programmers can use. I imported \"java.util\" into a scrapbook in Eclipse and inspected the following code.

3条回答
  •  暖寄归人
    2020-12-06 19:58

    Your Java version in Eclipse is set to 1.4, generics in java were introduced only in Java 5.

    Change your JDK to 1.5 or above in eclipse that will resolve this issue.

    You can check your JDK by Project - > Java Build Path - > Libraries

    If here you see it being Java 1.5 or above then check the compiler Compliance is set to 5 and above.

    You can check that Project - > Java Compiler

    EDIT:

    To add new jdk to Eclipse

    Right click on Project - > Java Build Path - > Libraries - > Add Libraries - > JRE System Library - > Installed Libraries - > Add - > Standard VM - > Provide your installation location and press OK

    Note in the list of Installed JRE, ensure that you check your Java 7.

提交回复
热议问题