Error :,
When running the principal project on AS this evening, the following error is reported:
Error :( 71, 35) Error:-source 1.6 does not support the diamond operator (use-source 7 or later to enable the diamond operator)
The code in the program corresponding to this error is:
Generally, the correct method is to specify the type during the Declaration, that is:
List <PublicBlogListBean> _ hotDatas = new ArrayList <PublicBlogListBean> ();
However, a new feature is added to JDK 1.7:
Enhanced type inference for general-purpose instance creation (diamond:
Type inference is a special headache. The following code:
Map <String, List <String> anagrams = new HashMap <String, List <String> ();
After the data type is inferred, it becomes:
Map <String, List <String> anagrams = new HashMap <> ();
This <> is called the diamond (diamond) operator, which infers the type from the referenced declaration.
That is to say, after JDK1.7 supports such type inference, The PublicBlogListBean type can be added to the new ArrayList <> when declaring _ hotDatas.
-The diamond operator is not supported in soure1.6. Diamond types are not supported at this language level. The current JDK version is not supported, but the JDK path of the Project is 1.7...
In fact, the project has not configured Source code Compatibility for the module, that is, Set Source Compatibility and Target Compatibility to 1.7:
After clicking OK, gradle will be re-built. Just click OK under the reload Project ~
You can also directly configure it in build. gradle:
Related Resources:
Jdk1.7 New Features
AndroidGradlePlugin Guide (6) Advanced build Customization