Difference between revisions of "Arrays"

From CompSciWiki
Jump to: navigation, search
Line 15: Line 15:
 
=[[Out of Bounds and One off Errors]]=
 
=[[Out of Bounds and One off Errors]]=
 
=[[Processing Arrays (using for loops)]]=
 
=[[Processing Arrays (using for loops)]]=
*length attribute
+
*length attribute
 
**print content of array
 
**print content of array
 
**copying arrays
 
**copying arrays

Revision as of 15:52, 20 March 2007


Wiki 1010 Table of Contents

Chapter #

(Graham)

This section will discuss how to create arrays, use elements in arrays, as well as other various topics listed in the index.

Arrays are important in Java, since they can be used to store multiple pieces of data. You can at any time add, edit, or modify the elements within an array. In addition, you can at any time remove the elements from the array.

You can think of an array as a table of contents for a book. The array contains the exact location of the data you "insert" into it, so you can access it at any time. You can also modify elements contained in an array outside of the array, and both copies will be simultaneously changed.

Arrays have many things you need to consider when using, such as that you can never change the length of an array without losing the elements inside of an array. In addition, you may not ask for elements past the end of an array. We will discuss these and more in further detail later in the chapter.

  Write a Program a Day Case Studies





Table of Contents



Creating Arrays

Entering and Using Array Elements

Out of Bounds and One off Errors

Processing Arrays (using for loops)

*length attribute
    • print content of array
    • copying arrays
    • comparing arrays
    • summing values
    • finding average of values
    • find highest and lowest values

Review Questions and Exercises