Java collections for Mainframe programmers

Java, Mainframe Jobs
(Java, Mainframe Jobs)

What is collections:

Collections provide the ability to manage groups of objects. A collection can be ordered or unordered, contain duplicates or not, depending upon the particular implementation chosen. Collections can also contain key-value pairs to provide a facility for maintaining in memory an index of objects.

How mainframe programmers should understand collections:

One useful way to understand collections is to compare them to traditional COBOL files. COBOL programs can traverse a file in a particular order, looking for specific records, and then modify or perhaps delete those records. In order to examine or modify any particular record, the program must first read it into a record structure. Standard functions exist to read, update, delete, and reorder (sort) the file. Further, the file has a determinate number of records, and the program can detect when it has reached the end of the file.

All COBOL programmers know how to process files. Data stored in files is readily available to a COBOL program. If you need to build a program that processes this file, all you need to know is where the file is stored and its record layout. The COBOL developer can concentrate on the business problem to be solved and efficiently use the syntax appropriate to process a COBOL file.

How Java collections differs:

  1. Java collections are stored in memory, not on disk (although you can certainly extend the basic collection class to provide for disk storage).
  2. Multiple users (that is, programs) can simultaneously access files, whereas collections are contained in a single runtime instance.
  3. 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 selection and file definition to a subroutine, allowing the subroutine to read and update the file. (Actually, some COBOL compilers do allow this!)
  4. 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 object. 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 ordered in some fashion, and others may be unordered. A collection type might allow duplicates, whereas another implementation might not.

You cane read more details in next post how to implement collections.


Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.