posted 12 years ago
It's perfectly ok to make a variable of a type that is an interface refer to an object of a class that implements the interface. For example, you can write:
Note that List is an interface, and ArrayList is a class that implements the List interface. The rest of the program, that uses list, only needs to know that it is an object of a class that implements List; it doesn't need to know that it's actually an ArrayList (or some other implementation such as LinkedList).
Likewise, the method Executors.newFixedThreadPool returns an object that's an instance of a class that implements the ExecutorService interface. You don't need to know what that exact class is to be able to use the ExecutorService.