It is preferred because:
- If later on code needs to be changed from ArrayList to Vector then only at the declaration place we can do that.
- The most important one – If a function is declared such that it takes list. E.g void showDetails(List list);
When the parameter is declared as List to the function it can be called by passing any subclass of List like ArrayList,Vector,LinkedList making the function more flexible
No comments:
Post a Comment