Diamond types are not supported at language level ‘5‘

Posted 石头StoneWang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Diamond types are not supported at language level ‘5‘相关的知识,希望对你有一定的参考价值。

摘抄自本人博客,详细可以参考:

https://blog.csdn.net/w8y56f/article/details/117825442

如何解决

Diamond types are not supported at language level ‘5’

解决方法

修改language level即可能可以临时解决

diamond指钻石,即钻石符号(<>),长得像钻石吧!

所以看到diamond这个单词,就要想起这个符号,sql里也用这个表示 “不等于”。jdk5里虽然有泛型的写法,但是这种写法List<String> list = new ArrayList<>();只有jdk7之后才能用钻石符号,否则就怪怪不省略,使用 List<String> list = new ArrayList<String>();

在这里插入图片描述

为什么说可能是临时的解决方案?

因为对于非maven的项目,你在Project Structure里Modules里改了Language level就是改了,但是对于maven项目,你改了有可能会打回原型,必须配置

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

PS: 下面是细节,以前我以为 Diamonds 是指泛型,犯过错,曾经也稀里糊涂
在这里插入图片描述

以上是关于Diamond types are not supported at language level ‘5‘的主要内容,如果未能解决你的问题,请参考以下文章

[2016-05-24]OMG美语笔记-Witch type of people are not your favorite people?

paddle报ValueError: The type of data we are trying to retrieve does not match the type

paddle报ValueError: The type of data we are trying to retrieve does not match the type

paddle报ValueError: The type of data we are trying to retrieve does not match the type

(2/2)ts are not on .

You are not late! You are not early!