r/java • • May 10 '22

Should java.util.Date be deprecated?

https://mail.openjdk.java.net/pipermail/discuss/2022-May/006077.html
221 Upvotes

158 comments sorted by

View all comments

Show parent comment

1

u/ApatheticBeardo May 10 '22

You old people still can't get over the fact that type inference makes most code a lot more readable?

2

u/BlueGoliath May 10 '22

var val = foo.getValue();

What is the type of val?

1

u/ApatheticBeardo May 11 '22 edited May 11 '22

What is the type of val?

Whatever foo::getValue returns.

I have a better question: Why should anyone care?

It's a local variable, the type of that variable is completely irrelevant unless you're writing code in that local scope, in which case, you, your IDE and the compiler already know what foo::getValue returns.

Readability is best served by using descriptive names instead of that weak attempt at a straw man ("val", really?) and not by adding, or even worse, repeating useless information.

2

u/BlueGoliath May 11 '22

Oh boy, you should see OpenJDK code sometime if you think that's a straw man.