Java Reference
In-Depth Information
Chapter 7
Arrays
Introduction
7.1 Array Basics
Constructing and Traversing
an Array
The sequential nature of files severely limits the number of interesting
things that you can do easily with them.The algorithms we have examined
so far have all been sequential algorithms: algorithms that can be per-
formed by examining each data item once, in sequence. An entirely differ-
ent class of algorithms can be performed when you can access the data
items multiple times and in an arbitrary order.
Accessing an Array
A Complete Array Program
Random Access
Arrays and Methods
The For-Each Loop
Initializing Arrays
The Arrays Class
This chapter examines a new object called an array that provides this
more flexible kind of access.The concept of arrays is not complex, but it
can take a while for a novice to learn all of the different ways that an array
can be used. The chapter begins with a general discussion of arrays and
then moves into a discussion of common array manipulations as well as
advanced array techniques.The chapter also includes a discussion of special
rules known as reference semantics that apply only to objects like arrays
and strings.
7.2 Array-Traversal Algorithms
Printing an Array
Searching and Replacing
Testing for Equality
Reversing an Array
String Traversal Algorithms
7.3 Reference Semantics
Multiple Objects
7.4 Advanced Array Techniques
Shifting Values in an Array
Arrays of Objects
Command-Line Arguments
Nested Loop Algorithms
7.5 Multidimensional Arrays
Rectangular Two-Dimensional
Arrays
Jagged Arrays
7.6 Case Study: Benford's Law
Tallying Values
Completing the Program
425
 
Search WWH ::




Custom Search