tags:

views:

202

answers:

1

so one use the var keyword in c# for implicit type declaration; what is the java equivalent?

+8  A: 

There is none. Alas, you have to type out the full type name.

Mike Caron
noooooooooooo, grrrr, gonna crack open the java creator :P
Arturo
To be fair, the only reason C# has `var` is because it is possible to instantiate types that have no name. There do not exist such types in Java.
Mike Caron
And to be fair also; 1. it's only recent in C#, so Arturo can't be blaming "creators" and 2. it's only due to some other features that weren't in the 1.0 of either language that its become an idea that is useful rather than a great way to make code less clear and more bug-prone. It's needed in C#3.0, and would have a few useful cases in C#2.0, but would have been a bad thing in C#1.0.
Jon Hanna