Error :,

Source: Internet
Author: User

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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.