Java Reference
In-Depth Information
processes this file, all you need to know is where the file is stored and its record lay-
out. The COBOL developer can concentrate on the business problem to be solved
and efficiently use the syntax appropriate to process a COBOL file.
The preceding descriptions are (more or less) the characteristics of Java collec-
tions. It is also helpful to note that collections have the following differences:
Java collections are stored in memory, not on disk (although you can certainly
extend the basic collection class to provide for disk storage).
Multiple users (that is, programs) can simultaneously access files, whereas col-
lections are contained in a single runtime instance.
Java collections can be passed as parameters to functions and can be returned
as the return item from a method. This would be similar to passing the file se-
lection and file definition to a subroutine, allowing the subroutine to read and
update the file. (Actually, some COBOL compilers do allow this!)
Java collections store references to objects, not the objects themselves. When
you add an object to a collection, you are simply adding a reference to the ob-
ject. You are not cloning the object and creating a copy of it.
A collection is a set of related objects or elements. One collection may be or-
dered in some fashion, and others may be unordered. A collection type might allow
duplicates, whereas another implementation might not.
The basic collection interface supports a few bulk operations , or methods that
can be used to move many elements at one time. As an added bonus, the contents
of a collection can be easily moved into arrays and out of arrays.
These are some of the interface definitions in Java's Collection framework:
Set: An interface for implementing classes that support groups of elements
that cannot contain duplicates. Elements in a Set are not ordered in any par-
ticular fashion.
List: An interface for a class that supports groups of ordered elements. Ele-
ments in a List can contain duplicates. Elements in a List are often accessed
using an index (or subscript) in a manner very similar to arrays.
Map: An interface for a class that maps key elements to values (i.e., other ob-
jects). It is roughly analogous to an indexed (ISAM) file in COBOL, where a key
is mapped to a record (a file that is contained in memory).
SortedSet: An extension of the Set interface. Elements in a SortedSet collection
are automatically ordered in some fashion, either through the natural ordering
of the elements or because an explicit Comparator object provides for an order-
ing algorithm.
Search WWH ::




Custom Search