Does Java 10 provide a val keyword? If not, why not?

后端 未结 3 1473
后悔当初
后悔当初 2021-02-03 18:58

Java 10 brings a C#-like var keyword for local type-inference.

But does Java 10 also provide a val keyword, as is found in Scala?

3条回答
  •  时光取名叫无心
    2021-02-03 19:37

    Because there is final var for that in Java. If we had val too, there would be two things that mean the same. This is not good. There should be only one way to express a particular thing.

提交回复
热议问题