{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


15-07mar13arrays - C S100J 1 3 M arch 2 006 A r r a y s R e...

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

View Full Document Right Arrow Icon
1 1 CS100J 13 March 2006 Arrays. Reading: Secs 8.1, 8.2, 8.3. Listen to the following lectures on loops on your Plive CD. They are only 2-3 minutes long, and each has an insightful message. 1. The three lectures on Lesson page 7-6 —read the whole page. 2. The four lectures in Lesson page 7-5. Start reading Secs. 8,1, 8.2, and 8.3 on arrays. Computational simplicity If you are writing too much code —it gets longer and longer, with no end in sight: stop and look for a better way . If your code is getting convoluted and you have trouble understanding it: stop and look for a better way . Learn to keep things simple, to solve problems in simple ways. This sometimes requires a different way of thinking. We are trying to teach not just Java but how to think about problem solving. A key point is to break a problem up into several pieces and do each piece in isolation, without thinking about the rest of them. Our methdology for developing a loop does just that. 2 Arrays An array: an object that can hold a fixed number of values of the same type. Array to the right contains 4 int values. 5 7 4 -2 a0 A declaration has the basic form < type > < variable-name > ; A declaration of x looks as to the right. The declaration does not create the array, it only declares x. x’s initial value is null . int [] x ; 0 1 2 3 Elements of the array are numbered 0, 1, 2, …, x.length–1; length is a variable, not a function, so don’t put () after it.
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
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}