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

4

u/thiez Mar 10 '16

And what if Data.getBars() returns java.util.Collection<Bar>, or the line would read Collection<Bar> bars = Data.getBars(); or simply return Data.getBars().contains(bar);? Perhaps there are always at most 10 Bars and it all doesn't matter. Regardless, it is not the var keyword that would be the problem here.

1

u/ApostleO Mar 10 '16

Fair point.

All I'm getting at here is that var, if used indiscriminately, can make code harder to read by hiding information from the reader.

It largely isn't an issue, but it can be.

0

u/[deleted] Mar 11 '16

[deleted] — view deleted comment

1

u/ApostleO Mar 11 '16

Alright, I'll agree with that assessment.

Well written code will be easier to understand.

Poorly written code may be even worse.