{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

10-17 Class Notes CS 107 - 10-17 Class Notes CS 107 Monday...

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

View Full Document Right Arrow Icon
Make sure to sign up for advising this week. 1. Program #4 (WordLine): Remember that if input is invalid for any reason, you disable a line of characters and also deduct a point from the score. 2. You must remove the package line of code from the top of each of your files that you turn in for program #4. 3. Announcements: Questions? Sample midterm #2 exam: solution shown in class, Introduction to arrays Last Time: More on Arrays Today: Arrays: Sample code done in class: // initialize values values[ i] = i*2; for( int i=0; i<values.length; i++) { } type[ ] arrayName ; where type can be any type (e.g. char, int, float), arrayName is an identifier you make up size indicates how many items will be stored in the array. We then must initialize the array using: arrayName = new type[ size] ; For example int[ ] scores; scores = new int[ 10] ; Syntax for Array Declaration 10-17 Class Notes CS 107 Monday, October 17, 2011 2:44 PM CS 107 Fall 2011 Page 1
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
Store a value scores[ 3] = 75; // store 75 into array element 3 (the 4th element) a. Retrieve a value from an array System.out.println( scores[ 1]); sum = sum + scores[ i];
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}