Can some explain the fist example says infers the type is right there in black and white var foo = new ArrayList (); It literally says exactly what foo is !!
Yes, but in current Java one would have to write ArrayList foo = new ArrayList () Or, at least List foo = new ArrayList () Whereas with `var`, as you show, the compiler infers the type. Proponents of this point out exactly what you did: the type is right there , so why should the programmer have to write it twice?
List foo = new ArrayList()
> so why should the programmer have to write it twice?
You wouldn't.