lecture13-arrays2

lecture13-arrays2 - cture 13: Arrays (cont d) Lecture 13:...

This preview shows pages 1–8. Sign up to view the full content.

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

View Full Document

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

View Full Document

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cture 13: Arrays (cont d) Lecture 13: Arrays (cont d) CS 170, Section 000 5 October 2009 15 October 2009 10/20/2009 CS170, Section 000, Fall 2009 1 Lecture Plan Arrays review (Ch 6.1-2) rray copying, passing to/from methods (Ch. 6.3- ) Array copying, passing to/from methods (Ch. 6.3 5) Last 5 minutes: Homework 4 overview (due Wed Oct 21 st ) 10/20/2009 CS170, Section 000, Fall 2009 2 Creating Arrays datatype arrayRefVar; Example: int numbers; arrayRefVar = new datatype[arraySize]; Example: numbers = new int[12]; 3 Declaring and Creating an Array in One Step atatype ] rrayRefVar Datatype arrayRefVar; arrayRefVar = new datatype[arraySize]; datatype arrayRefVar = ew atatype rraySize ; new datatype[arraySize]; ample: Example: int numbers = new int[12]; 4 ssigning Values to Array Elements Assigning Values to Array Elements arrayRefVar[index] = expression ; Example: myList[0] = 5.6; yList[1] = 4 5; myList[1] = 4.5; myList[9] = 11123; 5 The Length of an Array Once an array is created, its size is fixed. It cannot be changed. You can find its size using arrayRefVar.length For example: int numbers = new int[10]; nt en umbers length / / 1 6 int len = numbers.length; // 10 Accessing Array Elements The array elements are accessed through the...
View Full Document

This note was uploaded on 04/03/2010 for the course CS CS 170 taught by Professor Eugeneagichtein during the Fall '09 term at Emory.

Page1 / 20

lecture13-arrays2 - cture 13: Arrays (cont d) Lecture 13:...

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

View Full Document
Ask a homework question - tutors are online