Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why return IList rather then ArrayList?

807607Oct 31 2006 — edited Oct 31 2006
Hello to all, basically this one is a simple question. In many books I read I usually find code something as the following:
public IList getData(){

	IList data = new ArrayList();

	// � retrieving data.

	return data;
}
Now my question is, why do they return the interface rather then the implementation of an object? Is there maybe some performance gain? Or it is just a coding style?

Thanks and Regards,
Sim085
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 28 2006
Added on Oct 31 2006
13 comments
338 views