content









Content









7.4
Using
Arrays




7.4.5
Reusing
an array




The array variable is separate from the
array itself. It is similar to the way an ordinary variable can access
different values at different times. Use array variables to access
different arrays at different points in the program. For example, a
teacher could have several courses for which data is being stored. The
code for the main method of the TeacherExample class reuses the array variable
that is a reference to an array object of JavaStudent object
references .
In this example, it is assumed that the
TeacherExample class saves the JavaStudent arrays in a file. It is not
implied that a teacher has to create this student information again
and again. Chapter 13 will demonstrate how to take object data in
memory and save it in a file. This allows the data to persist beyond
the program.





















Lab
Activity



 

Extended
use of Arrays
This lab will create a class called PickADay
with an array of Strings initialized with the
seven days of the week. This class will utilize
a class constructor to create a random number
that will be used to index a day in the array.













 










Wyszukiwarka

Podobne podstrony:
content
content
content
content
content
content
content
content
content
function domnode get content
content
content
content
content
content
content

więcej podobnych podstron