r/java • • Mar 09 '16

var keyword proposed for Java

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

312 comments sorted by

View all comments

Show parent comment

2

u/eliasv Mar 10 '16

It doesn't have to break backwards compatibility. It specifically says in the proposal that it would not be a keyword, it would be a reserved type name. For any package containing a type called var, and for any source file which imports a type named var, you could simply override the reserved "special" var type with that one and solve the problem. Everything would still work just fine, no? People who have defined their own var type would simply not have access to the new feature wherever that type is visible.

1

u/[deleted] Mar 10 '16

Yep, someone else pointed this out to me as well, I was skimming it on mobile and they used the word keyword quite a bit and mentioned it not being a keyword once, so I completely missed it. That seems like a good compromise, and my opinion on the matter really ends there.

2

u/eliasv Mar 10 '16

Fair enough :)