Java Reference
In-Depth Information
returns all cameras for sale. You could use a list to hold the data and iterate through the list
to display the cameras in an HTML table.
Figure 7. 2 shows the List interface and the classes in the Collections Framework that
implement List .
FIGURE 7.2 The List interface and its implementing classes
interface
List
class
ArrayList
class
LinkedList
class
Vector
class
Stack
The different list classes each provide their own unique functionality:
ArrayList A resizable list implemented as an array. When elements are added and
removed, the ArrayList grows and shrinks accordingly. You can control the internal size of
the array to improve performance.
LinkedList A list that implements a linked list data structure. Items can be added and
removed from the beginning or end of the linked list. LinkedList is unique in that it also
implements the Queue and Deque interfaces.
Vector A Vector is essentially the same as an ArrayList except that the methods in
Vector are synchronized.
Stack A list that implements a stack data. Items are pushed onto the top and popped off
the top of the stack, a last-in, fi rst-out (LIFO) behavior.
The basic operations of List include the ability to add a single element at a specifi ed
index, add a collection of elements, replace or remove a specifi c element, and retrieve an
element at a specifi ed index.
Sets
A set is a collection of elements that does not allow duplicates and models the mathematical
concept of abstract sets. For example, the Set interface contains an andAll method for
performing set unions and a retainAll method for performing set intersections. Use
Search WWH ::




Custom Search