How to fix '<>'operator is not allowed for source level 1.7
eclipse, java
Solution
Sometimes I have seen Eclipse become confused about the Java target version, and throw incorrect messages (even if the project is set up correctly to support Java 7). The easiest way to fix it is to change the target version, then change it back to the expected target version.
This version can be checked by opening the Project properties dialog (right click on the project, and select `Properties`), and check the settings on two tabs:
- `Java Compiler` tab: Check whether there are any specific settings such as always use a JDK version, etc. By default, all settings here are set to "Use compliance from execution environment 'JavaSE-1.x' on the 'Java build path'." (where x is a Java version). If a specific Java version (pre-Java 7) is selected here, then select the one you are targeting, and you should be done. If the previously mentioned checkbox is set, then follow to step 2.
- `Java build path` tab: Go to libraries, and edit the JRE system library accordingly.
Again, if both settings seem correct, change the latter, rebuild your project (e.g. close your dialog), then change it back and rebuild.
Remarks: if you are using a Maven/Gradle project, it is possible that you should edit these settings in the Maven/Gradle configuration.
Problem
I am using JDK 1.8.0. When I import the code into Eclipse I am getting the error: '<>'operator is not allowed for source level 1.7 Example: ``` List<String[]> errors = new ArrayList<>(); ``` I am using Eclipse Kepler.