ArrayList assigned to List
1 posts in topic
Flat View  Flat View

Posted By:   Anonymous
Posted On:   Wednesday, December 14, 2005 03:03 AM

Why do they assign ArrayList object to List like
List ls=new ArrayList() when we can create objects like
ArrayList al=new ArrayList().

Re: ArrayList assigned to List

Posted By:   ankush_purwar  
Posted On:   Wednesday, December 14, 2005 04:16 AM

Because A List can be ArrayList, vector, linklist etc.

The caller didn't take care about specific classes, he doesn't know what is the exact implementation of this class.

It's actually the Object oriented design.
'Dependence inversion principle'
means Always depend on abstraction not on the implementing classes.
About | Sitemap | Contact