Chapter 11 - Chapter11 Arrays Arrays,Whatare...

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

View Full Document Right Arrow Icon
Chapter 11 Arrays
Background image of page 1

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

View Full DocumentRight Arrow Icon
Arrays, What are Arrays provide a way to store lots of  similar data under one variable name They also allow easy access to this data  using loops Arrays cannot contain more than one data  type…. but there are ways around this!
Background image of page 2
Indices An array is stored under one name. To  access each individual element, you use  indices.  numbers[0]; //first element numbers[1]; //second element numbers[n-1]; //last element
Background image of page 3

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

View Full DocumentRight Arrow Icon
Ooops If you like getting cool errors, try this: //Create an array of size 10 and then… x = array[10]; Don’t index an array past it’s bounds!
Background image of page 4
Creating Arrays Here’s the syntax: double [] 3Dvector = new double[3]; //Array of three doubles This is the declaration: double [] 3Dvector; This is the assignment: 3Dvector = new [3]; or 3Dvector = someOtherDoubleArray;
Background image of page 5

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

View Full DocumentRight Arrow Icon
Arrays are Objects too, you know… An ‘empty’ array variable is a reference or 
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/28/2011 for the course CS 1131 taught by Professor Staff during the Fall '08 term at Michigan Technological University.

Page1 / 12

Chapter 11 - Chapter11 Arrays Arrays,Whatare...

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

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