|
|
|
|
|
by henrikschroder
5776 days ago
|
|
With the var keyword the variable will be the exact same type as what you initialize it to, not an interface. List<Foo> list = new ArrayList<Foo>();
...is programming towards an interface, whereas var list = new ArrayList<Foo>();
...isn't, because the type of list will be ArrayList. I think his point was that with the new Java stuff you could instead do List<Foo> list = new ArrayList<>();
...which would then be explicitly programming towards an interface, while still not having to type so bleeding much. |
|