File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Why java.util.AbstractSequentialList has some methods implemented?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Why java.util.AbstractSequentialList has some methods implemented??" Watch "Why java.util.AbstractSequentialList has some methods implemented??" New topic
Author

Why java.util.AbstractSequentialList has some methods implemented??

Ryan Raina
Greenhorn

Joined: Jun 16, 2010
Posts: 28
Hello All


While seeing the source code of AbstractSequentialList it looks like it gives implementation of some of the methods ..I am not able to understand why??

Take a look at the declaration of LinkedList class

public class LinkedList<E>
extends AbstractSequentialList<E>
implements List<E>, Deque<E>, Cloneable, java.io.Serializable

LinkedList will inherit all methods of collection,List,AbstractList,AbstractCollection and also AbstractSequentialList.....

It looks like LinkedList class overrides all the implemtations present in AbstractSequentialList...and also AbstractSequentialList is not used anywhere by any other class
Why does it give implemention or say why to have it in first place??


Also I saw same thing in case of AbstractList class ...All subclass whether ArrayList or AbstractSequentialList override the behaviour..
But this class has more to do with vector class which extends its methods and doesn't override it..so that fine..

What is your say on this guys??

Thanks for your help always



Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8043
    
  22

Ryan Raina wrote:Why does it give implemention or say why to have it in first place??

Usually because it's a convenience for the developer.

If you look at the docs for AbstractSequentialList, you'll notice that it says in the very first sentence:
"This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "sequential access" data store (such as a linked list)."
and I've certainly found the AbstractList class extremely useful.

As to why LinkedList overrides all the implementations, you'd have to ask the designer of the class. I hate to say, but "why" questions like this based on looking at source code will almost always get the same answer, because any guess on our part would be pure speculation.

I'd also suggest that looking at foundation class source code may not be the best use of your time, because the whole point about object-orientation is to hide implementation - and whatever you do, NEVER write programs that rely on source code that you've looked at.

If you want to get information on programming techniques, you'd be far better of getting a decent book on the subject.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Ryan Raina
Greenhorn

Joined: Jun 16, 2010
Posts: 28
Thanks Winston Gutkowski for your response

My purpose of viewing the source code to to understand the overall architecture of the collection API

I want to learn how to architect a web application from the scratch...so i thought java API might be a good learning...

I know most of the design patters and have used them also but the thing is that I want to understand how one should be able to design an web app from scratch..

Can you suggest some books or material that would help me going about this...I am a good programmer but designing is not my stuff...so kinda want to learn that part...

Anyways I thank you for your response ...specially for this
I'd also suggest that looking at foundation class source code may not be the best use of your time, because the whole point about object-orientation is to hide implementation - and whatever you do, NEVER write programs that rely on source code that you've looked at.


This was useful

 
Consider Paul's rocket mass heater.
 
subject: Why java.util.AbstractSequentialList has some methods implemented??