For example instead of:
LinkedStack<Integer> list = new LinkedStack<Integer>();
Should be this:
StackInterface<Integer> list = new LinkedStack<Integer>();
For example instead of:
LinkedStack<Integer> list = new LinkedStack<Integer>();
Should be this:
StackInterface<Integer> list = new LinkedStack<Integer>();
In my opinion:
LinkedStack<Integer> list = new LinkedStack<Integer>();
is better only if you need specific methods on LinkedStack that are not declared in StackInterface
.
StackInterface<Integer> list = new LinkedStack<Integer>();
is better if you do not, because then you can 'plug in' any implementer of the interface for different reasons (efficiency reasons for example).
The second way is called code to interfaces.
second way is prefarable like. use interface as refference for subclass object.