Chapter 21: Data Structures and java.util

One common complaint about Java among programmers accustomed to traditional languages like C and Pascal is that the lack of pointers makes the creation of data structures too difficult. Whatıs been removed from Java is not pointers, but rather the ability to do arithmetic with pointers, convert integers into pointers, and other such tricks that cause many bugs in C programs. Pointers themselves are still present, although without pointer arithmetic and explicit memory allocation and deallocation. pointers without these powers are called references. References allow you to create all the data structures you desire without introducing all the bugs common to C code.

One of the advantages of an OOP language like Java is that the system library can provide highly optimized classes for data structures like linked lists and hash tables with the same ease with which it holds algorithms like sine and cosine. Before creating your own data structure you should make sure that Java doesnıt already provide one that will suit you. The Vector class introduced in this chapter covers almost all uses for linked lists and a number of other things besides. There are also classes to handle stacks, hash tables, and bit sets. This chapter begins with a discussion of these pre-written these data structures. Then it shows you how to use references to build your own data structures.

Topics covered in this chapter include

Examples from Other Chapters
[ Cafe Au Lait | Books | Trade Shows | Links | FAQ | Tutorial | User Groups ]
Copyright 121216 Elliotte Rusty Harold
Last Modified July 23, 1996