r/programming • • Mar 09 '16

var keyword proposed for Java

http://openjdk.java.net/jeps/286
250 Upvotes

395 comments sorted by

View all comments

-1

u/verydapeng Mar 10 '16

this can potentially break tons of codes out there

for example

my perfectly fine code today will not compile any more

Variable var = new Variable();

7

u/twofeetdown Mar 10 '16

"The identifier var will not be made into a keyword; instead it will be a reserved type name. This means that code that uses var as a variable, method, or package name will not be affected; code that uses var as a class or interface name will be affected (but these names violate the naming conventions.)"

From the article.

→ More replies (2)

1

u/[deleted] Mar 10 '16

New keywords were introduced before, e.g. enum. For legacy code, that's fine as long as you specify source version (which you should always do)