M/F 2:30-3:20 |
CS 1130: Transition to OO Programming Spring 2016 |
Main
About: Overview Announcements Staff Consultants Calendar Materials: Texts DrJava Terminology Lectures: In-Class Web-Based VideoNote Assessment: Grading Assignments Labs Resources: CMS Piazza (link) Piazza (about) Java API Style Guide Academic Integrity |
ArraysIntroductionJava, like most programming languages, has arrays —lists of elements of a certain type, where the size of a list is fixed when the array is first created. In Java, arrays are objects. We provide a very brief summary of one- and two-dimensional arrays. Turn to Chapter 8, pp. 271–297, of Gries/Gries for complete discussion of one-dimensional arrays. Read Chapter 9, pp. 301–311 to see how a two-dimensional array is handled as an array of arrays. Declaration of one-dimensional array variablesUse
to declare a variable Note that Creation of an arrayEvaluation of the new-expression
creates an array that contains <integer-expression>
elements, all of type <type>. So,
below we create an array of 10
The number of elements in the arrays are given by Referencing and changing array elementsArray indexing starts at
and the following procedure call sets the title of
Two-dimensional arraysA two-dimensional
To create a two-dimensional 20-row by 30-column
The number of rows, To add
|