in a java program , I have the following line of code :
HashMap<String, String> query_args = new HashMap<>();
and i receive the following error:
'<>' operator is not allowed for source level below 1.7
I tried to change the project compliance and jre to 1.7 but then eclipse could not resolve the imports. I am using jre 1.6.
Any suggestions?
Prior to Java 7 (1.7 here), you needed to do
HashMap<String, String> query_args = new HashMap<String, String>();
Its referred to as the diamond operator, and is not backwards-compatible with earlier versions of Java.
Because that wasn't introduced until Java 7. I really don't know how else to answer that question, besides chronicling the history of Java.
Regarding imports, you should research why Eclipse cannot resolve whichever imports they are when set to Java 1.7, and if needed post that as a separate question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With