That expression would actually return Class<?>. So you would have to cast it to Class<Bar> with or without the var keyword. Doing this solves your problem.
var c = (Class<Bar>) Class.forName("com.foo.Bar");
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.
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.
9
u/ElvishJerricco Mar 09 '16
That expression would actually return
Class<?>. So you would have to cast it toClass<Bar>with or without thevarkeyword. Doing this solves your problem.