This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 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 Fxed 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. xs initial value is null . int x ; 1 2 3 Elements of the array are numbered 0, 1, 2, , x.length1; length is a variable, not a function, so dont put () after it....
View Full Document
This note was uploaded on 03/03/2012 for the course CS 100J taught by Professor Davidgries during the Spring '07 term at Cornell University (Engineering School).
- Spring '07