I CSI 201 Chapter 7: Introduction to Arrays

61 views3 pages

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. 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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents