Skip to main content Accessibility help
×
Hostname: page-component-848d4c4894-ndmmz Total loading time: 0 Render date: 2024-06-03T20:39:17.636Z Has data issue: false hasContentIssue false

Chapter 8 - Arrays

Published online by Cambridge University Press:  26 August 2009

E. Reed Doke
Affiliation:
University of Arkansas
Bill C. Hardgrave
Affiliation:
University of Arkansas
Richard A. Johnson
Affiliation:
Southwest Missouri State University
Get access

Summary

OBJECTIVES

In this chapter you will study:

  • One-dimensional arrays;

  • Two-dimensional arrays;

  • Searching arrays; and

  • Passing arrays as arguments.

This chapter shows you how to work with arrays. You will learn how to define and manipulate both single and multidimensional arrays. In this chapter, as in others, we will develop real working programs to illustrate using Java arrays.

NOTES

  1. COBOL uses the terms single-level table; Java uses one-dimensional array.

  2. In keeping with the spirit of Java, here we will use array and dimension.

This chapter begins with the declaration and population of one-dimensional arrays, then illustrates how to declare and populate two-dimensional arrays. The examples use both numeric and string data values.

The chapter also describes how to search an array using Java and how to pass arrays as arguments to methods.

You will see that, although internally Java treats array processing somewhat differently than COBOL, Java array handling looks a lot like COBOL table processing to the programmer. Of course, we will continue to point out significant differences between Java and COBOL and the pitfalls to avoid when writing Java from a COBOL programmer's perspective.

This chapter assumes you understand the following:

COBOL:

Defining one & two level tables

Initializing one & two level tables

Table lookup techniques

Using subscripts and indexes

Perform-varying statement

Java:

OO concepts (Chapter 2)

Java program structure (Chapter 3)

Defining data (Chapter 4)

Decision making (Chapter 6)

Looping (Chapter 7)

DECLARING ONE-DIMENSIONAL ARRAYS

We begin our discussion of one-dimensional arrays by looking at loan processing for the Community National Bank (CNB).

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2004

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Arrays
  • E. Reed Doke, University of Arkansas, Bill C. Hardgrave, University of Arkansas, Richard A. Johnson, Southwest Missouri State University
  • Book: COBOL Programmers Swing with Java
  • Online publication: 26 August 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511546983.010
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Arrays
  • E. Reed Doke, University of Arkansas, Bill C. Hardgrave, University of Arkansas, Richard A. Johnson, Southwest Missouri State University
  • Book: COBOL Programmers Swing with Java
  • Online publication: 26 August 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511546983.010
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Arrays
  • E. Reed Doke, University of Arkansas, Bill C. Hardgrave, University of Arkansas, Richard A. Johnson, Southwest Missouri State University
  • Book: COBOL Programmers Swing with Java
  • Online publication: 26 August 2009
  • Chapter DOI: https://doi.org/10.1017/CBO9780511546983.010
Available formats
×