Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg7068951

WHAT YOU’LL LEARN IN
THIS HOUR:
.Creating an array
.Setting the size of an array
.Giving a value to an array
element
.Changing the information
in an array
.Making multidimensional
arrays
.Sorting an array

No one benefited more from the development of the computer than Santa
Claus. For centuries, humankind has put an immense burden on him to
gather and process information. Old St. Nick has to keep track of the fol-
lowing things:


. Naughty children
. Nice children
. Gift requests
. Homes with impassable chimneys
. Women who want more from Santa than Mrs. Claus is willing to let
him give
. Countries that shoot unidentified aircraft first and ask questions later


Computers were a great boon to the North Pole. They are ideal for the stor-
age, categorization, and study of information.


The most basic way that information is stored in a computer program is by
putting it into a variable. The list of naughty children is an example of a
collection of similar information. To keep track of a list of this kind, you
can use arrays.


Arraysare groups of related variables that share the same type. Any type of
information that can be stored as a variable can become the items stored in
an array. Arrays can be used to keep track of more sophisticated types of
information than a single variable, but they are almost as easy to create
and manipulate as variables.


HOUR 9


Storing Information with Arrays

Free download pdf