COP 3502 Lecture 18: Lecture 18
Document Summary
Up to this point we have used very simple data structures - Imagine that you had to read 100 numbers, computer their average, and find out how many numbers are above the average. Using what we"ve learned, you"d have to declare 100 variables. An array is a data structure that is a collection of the same type of data. double[] mylist = new double[10]; Basically a list in java mylist [5] = 6. 7; When you do this, position 6 in the list is equal to 6. 7. When an array is created, its elements are assigned the default value of. The array elements are acesed through the index. The array incides are 0-based ; it starts from 0 to arrayrefvar. length-1. Each element in the array is represented using the following syntax, known as an indexed variable. arrayrefvar[index]; After an array is created, an indexed variable can be used in the same way as a regular variable.