Free tutorials for Java, Eclipse and Web programming



Follow me on twitter

How to implement common datastructures (List, Stack, Map) in plain Java

Lars Vogel

Version 0.3

17.01.2010

Revision History
Revision 0.120.10.2009Lars Vogel
Splitted of from http://www.vogella.de/articles/JavaAlgorithms/article.html
Revision 0.221.10.2009Lars Vogel
Added list implementation
Revision 0.317.01.2010Lars Vogel
Removed reference to standard map in map implementation

List, Map and Stack implementations in Java

This article describes how to implement data structures (List Stack, Map) in Java.

The implementations in this articles are for demonstration and education purpose. They do not try to be as efficient as the standard libraries and they are not intended to be an replacement for the standard libraries.


Table of Contents

1. Datastructures
2. List
3. Map - Associative array
4. Stack
5. Thank you
6. Questions and Discussion
7. Links and Literature

1. Datastructures

Every programmer requires certain data structures for saving several elements. Usually every programming languages provides Arrays. These are fixed sized storage elements where every element can be addressed via an index.

The programmer usually requires a higher level of abstraction, e.g. Lists, Maps, Stacks, etc.

The Java programming language provides these elements very efficiently implemented in libraries. This article tries to describe how such elements could be implemented directly with Java constructs. The implementations in this articles are for demonstration and education purpose. They do not try to be as efficient as the standard libraries and they are not intended to be an replacement for the standard libraries.