当使用"var"时,编译时出现问题.在JDK 11中 [英] problem in compile time when using "var" in jdk 11
本文介绍了当使用"var"时,编译时出现问题.在JDK 11中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用"var"一词时, IDE会识别该命令,但是当我编译代码时,它给了我一个错误:
when I use the word "var" the IDE recognize the command, but when I compile the code, it gives me an error:
错误:(10,17)java:找不到符号
Error:(10, 17) java: cannot find symbol
符号:var类
位置:Exp类
代码:
public final class Exp
{
public static void main(final String[] args)
{
var x=5;
}
}
那为什么会发生呢?我该怎么解决?
So why does it happen? How can i solve it?
图片:
推荐答案
感谢@Marv解决方案是
Thanks to @Marv the solution was
设置->构建,执行,部署->编译器-> Java编译器
Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler
并将项目字节码版本提高到11.(我将其从8提高到11)
and raise the Project Bytecode version to 11. (I raised it from 8 to 11)
图片:
这篇关于当使用"var"时,编译时出现问题.在JDK 11中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文