3 ms·
Could you expand on what "program to an interface" means to you in this context, I'm not getting it. Assume that I know what it means in the usual context, of d
by StrawberryFrog 16y ago
Could you expand on what "program to an interface" means to you in this context, I'm not getting it. Assume that I know what it means in the usual context, of depending on the services of an interface type not a concrete type.
- henrikschroder 16y agoWith 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.
- StrawberryFrog 16y agoProgramming to an interface just doesn't seem so useful within the scope of a method.