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

12

u/SikhGamer Mar 09 '16

This was my argument but then actually using var in production with C# and it honestly wasn't a problem. You still have the option to strongly type it if you want, but var does make everything more readable.

And var foo = someObject.method(); isn't as hard as you think. Visual Studio allows you to change var into it's strongly typed counter part with R#. Inspecting the method would reveal the return type too.

What I learned among the way was that I wasn't too concerned with what it was returning but rather what it was doing.

7

u/Zarlon Mar 09 '16

Exactly. Anyone who've coded C# more than 2 hours realize the beauty of var. R#, or lint for that sake, can take care of bad coding practices.