I try to use the following code:
ArrayList<String>
Map<String, String>
Eclipse complains about both of them: Syntax Error, parameterized types are only if source level is 1.5.
I use JDK 1.6, but even if I go to compiler and switch the compliance to 1.5. It still give me this error. Any Idea why?
I have experienced the same problem with Eclipse Indigo release - even though the project set up was correct. The main cause I suspect is that the workspace is defined in a separate folder from the actual source folders (as mentioned user748337). To fix the problem, I had to enable the project specific settings option (in the Porject preference) although it wasn't different from the workspace settings.
Be wary, too, of inheriting workspace settings in your projects for Java Compiler/Compliance settings. I had a project that was imported into Eclipse. Eclipse generated the project with a J2SE 1.4 JRE, compiler, and compliance settings.
When I went in and manually updated these settings and un-checked the "Enable project specific settings" box, I was still receiving build errors relating to 1.5 level compliance (even though the workspace settings were clearly 1.6). It wasn't until I re-checked the "Enable project specific settings" box and manually set the compiler/compliance levels to 1.6 did the errors go away.
Do the following..
Right-click on your project--> select properties-----> select Java Compilers
You wills see this window
Image for reference
Now check the checkbox ---> enable project specific settings.
Now set the compiler compliance level to 1.6
Apply then Ok
now clean your project and you are good to go
THIS CAN BE A QUICK FIX FOR ECLIPSE
When I was trying to create array list it gave error that array list cannot be resolved to type and something about "parametrised type are only in level 1.5"
Only I did was I tried to import java.util.ArrayList;
And that error went away.
It can be resolved as follows:
Go to Project properties.
Then 'Java Compiler' -> Check the box ('Enable project specific settings')
Change the compiler compliance level to '5.0' & click ok.
Do rebuild. It will be resolved.
Also, click the checkbox for "Use default compliance settings".