Tag Info

Hot answers tagged

6

In both of your code snippets, the use of AbstractList is discouraged.1 The correct usage is to put the new instance of list in a List variable. The abstract classes AbstractList and AbstractSequentialList are provided for the convenience of implementers (i.e. library writers) of list-like containers, by providing default implementations(*) for some of the ...


3

I would like to understand the clear reason, Why additionally interface List is introduced? In Java, types form a directed acyclic graph, but classes form a tree. As such, types are strictly more flexible than classes. When designing APIs, you should prefer uses non-class types as much as possible for your parameters and your return types. And pretty ...


2

What you gain by following his recommendations is the ability to accept any object regardless of implementation as long as it implements an interface correctly. There's nothing special about this and it's a commonly-used technique. As the paper points out, what you lose is: The ability to restrict variables to a specific class, which matters when ...



Only top voted, non community-wiki answers of a minimum length are eligible