I CSI 201 Chapter Notes - Chapter 7: Linear Search, Search Algorithm
Document Summary
Primitive variables are designed to hold only one value at a time. Arrays allow us to create a collection of like values that are indexed. An array can store any type of data but only one type of data at a time. An array is a list of data elements. An array is an object so it needs an object reference. // declare a reference to an array that will hold integers. int[] numbers; The next step creates the array and assigns its address to the numbers variable. // create a new array that will hold 6 integers. numbers = new int[6]; It is possible to declare an array reference and create it in the same statement. int[] numbers = new int[6]; Arrays may be of any type. float[] temperatures = new float[100]; char[] letters = new char[41]; long[] units = new long[50]; double[] sizes = new double[1200]; The array size must be a non-negative number.