Title: Arrays Summary
Course: CPS 161: An Intro to Programming with Java - DL MM MASTER

Arrays Summary

Array Fundamentals

- Allocating and initializing arrays
- Using the length attribute to know the size of the array
- Legal indices and what happens when you access illegal indices
- Arrays of classes

Array Initialization & Method Parameters

- Default array initializations
- Classes stored in an array need to be constructed
- Short cuts for allocating and initializing arrays
- Parameter passing to methods:
  - Primitives
  - Arrays of Primitives
  - Mutable classes
  - Immutable classes (String, Wrapper classes like Integer, Double, etc.)

Array Miscellaneous

- Multiple references (or names) for the same array
- main(String[] args) - command line parameters
- Methods returning arrays
- Misconceptions and errors with arrays

Array Example: Standard Deviation

- Example: Calculate Standard Deviation calculation from an array of values.

Array Example: Common Birthday(integer date)

- Example: Given a room of N people what is the probability of at least 2 people having the same birthday. In this example we represent birthdays as random integers between 1 and 365.

ArraysExample: Common Birthday (using Date class)

- Example: Change the previous problem such that we represent birthdays as random "Date" classes.

Array Example: Unique Numbers

- Example: Given an array of numbers, remove the duplicate numbers and create a new array with just the remaining unique numbers.

Last Modified: May 31, 2014 3:56 PM