前端工程师的福音?Java 支持用 var 定义变量了
Starting with Java SE 10, you can use the var type identifier to declare a local variable. In doing so, you let the compiler decide what is the real type of the variable you create. Once created, this type cannot be changed.
从 Java SE 10 开始支持用 var
来定义变量了,变量的类型将由编译器自己推导,和 JS 的区别就是,这个变量的类型一旦确定就不能再更改了(静态语言毕竟还是静态语言 😂)。
这个特性也就看看,好多公司(包括我现在的公司)为了稳定,Java 版本到不了那么高。
参考资料