ArrayLab032009 - Java Programming CIS 106 Spring 2009 1...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Java Programming: CIS 106 Spring, 2009 1 Chapter 9 Introduction to Arrays Overview Chapter 9 introduces the concept of arrays. An array is a list of elements of the same data type. Objectives Declare and initialize an array Use subscripts with an array Declare an array of objects 1. Describe the syntax for declaring an array . Arrays are indicated using square brackets: double [] salesFigure; 2. Declaring an array does not reserve memory space for the array elements. The process of reserving memory space is called creating the array. The new operator is used to create an array: salesFigure = new double[20]; Teaching Tip An array can be declared and created in the same statement: double[] salesFigures = new double[20]; Initializing an Array 1. int [ ] tenVal = { 1,2,3,4,5,6,7,8,9,10}; //Initializes a ten element array . Using Subscripts with an Array 1 Instructor: Moore
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Java Programming: CIS 106 Spring, 2009 2 1. The power of arrays lies in using a variable as a subscript. This allows the array
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

ArrayLab032009 - Java Programming CIS 106 Spring 2009 1...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online