Apache web server tutorial - Chapter 21 Collections 1203 which is called the
Chapter 21 Collections 1203 which is called the Standard Template Library (STL). (See Chapter 20 of C++ How to Program, Third Edition, by H. M. Deitel and P. J. Deitel, 2001, Prentice Hall). The Java collections framework provides ready-to-go, reusable componentry; you do not need to write your own collection classes. The collections are standardized so applications can share them easily, without having to be concerned with the details of their implementation. These collections are written for broad reuse. They are tuned for rapid execution as well as efficient use of memory. The collections framework encourages further reusability. As new data structures and algorithms are developed that fit this framework, a large base of programmers already will be familiar with the interfaces and algorithms implemented by those data structures. 21.2 Collections Overview A collection is a data structure actually, an object that can hold other objects. The collection interfaces define the operations that a program can perform on each type of collection. The collection implementations execute the operations in particular ways, some more appropriate than others for specific kinds of applications. Thecollection implementations are carefully constructed for rapid execution and efficient use of memory. Collections encourage software reuse by providing convenient functionality. The collections framework provides interfaces that define the operations to be performed generically on various types of collections. Some of the interfaces are Collection, Set, List and Map. Several implementations of these interfaces are provided within the framework. Programmers may also provide implementations specific to their own requirements. The collections framework includes a number of other features that minimize the amount of coding programmers need to do to create and manipulate collections. The classes and interfaces that comprise the collections framework are members of package java.util. In the next section, we begin our discussion by examining the capabilities that have been added for array manipulation. 21.3 Class Arrays We begin our discussion of the collections framework by looking at class Arrays, which provides static methods for manipulating arrays. In Chapter 7, our discussion of array manipulation was low level, in the sense that we wrote the actual code to sort and search arrays. Class Arrays provides high-level methods, such as binarySearch for searching a sorted array, equals for comparing arrays, fill for placing values into an array and sort for sorting an array. These methods are overloaded for primitive-type arrays and Objectarrays. Figure 21.1 demonstrates the use of these methods. 1 // Fig. 21.1: UsingArrays.java 2 // Using Java arrays. 4 // Java core packages 5 import java.util.*; Fig. 21.1Using methods of class Arrays(part 1 of 3). Fig. 21.1 Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/12/01
Note: If you are looking for cheap and reliable webhost to host and run your web application check Vision coldfusion web hosting services