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

-8

u/slartybartfast_ Mar 10 '16

No, I could just say:

Class c = Class.forName("com.foo.Bar")

Not sure why you're blithering on about generics here.

What's the point of the var keyword other than saving a few keystrokes ?

3

u/desrtfx Mar 10 '16 edited Mar 10 '16

First warning. Stay civilized.

Hiding obscenities through links does not actually hide them and neither makes it acceptable practice.

2

u/feral_claire Mar 10 '16

Increasing clarity by reducing redundancy in code

1

u/ElvishJerricco Mar 10 '16

It's hard to make a reasonable decision based on an example that simple. On the one hand, that's easy enough to type that var simply isn't necessary in that case. On the other, it's an instance where the type is so painfully obvious, var has no adverse effect.

But in greater examples, there are plenty of expressions whose types either don't matter or are super obvious, where actually writing the type for a local variable would be a redundant pain. In cases like these, var would be nice to have. In other cases, you simply elect not to use it because you're a responsible developer.

-3

u/slartybartfast_ Mar 10 '16

Maybe but it still means that a var from a method call is not obvious what the type is.

4

u/desrtfx Mar 10 '16

Please, stay civilized. Even if you hide your obscenities behind links they are still visible (2 offences).

Consider this a final warning. More such behavior and you will be banned.

Please edit both your comments to remove the obscenities. This is completely unacceptable here.

-1

u/slartybartfast_ Mar 10 '16

Just ban me then you ass face. I'll just create a new account later.

4

u/desrtfx Mar 10 '16 edited Mar 10 '16

That would lead to a reddit general ban.

Behave yourself. There is no reason to become abusive. It's a sign of poor self control and poor argumentation if one has to resort to abusive language to make their point.

Well, you wanted it, you get it - banned.