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

Show parent comments

1

u/immibis Mar 10 '16

More likely:

var lst = new ArrayList<String>();
if(condition)
    lst = someMethodThatReturnsAList();

1

u/Eirenarch Mar 10 '16

I can claim that this code sucks because the original instance should not be created unless it is needed but instead I am just going to point out the fact that you cannot use var everywhere. The old syntax will still work and you should fallback to it on occasion.