The obvious solution to developers familiar to Java is to use the LinkedList class already provided in java.util.
Say, however, you wanted to make your own implementation for some
reason. Here is a quick example of a linked list that inserts a new link
at the beginning of the list, deletes from the beginning of the list
and loops through the list to print the links contained in it. Enhancements to this implementation include making it a double-linked list, adding methods to insert and delete from the middle or end, and by adding get and sort methods as well.
Note: In the example, the Link object doesn't actually contain another Link object - nextLink is actually only a reference to another link.
http://stackoverflow.com/questions/10042/how-do-i-implement-a-linked-list-in-java
No comments:
Post a Comment