Chapter Summary
An array can be thought of as a collection of variables all of the same type.
Arrays are objects that are created using the operator
new
, although the syntax is slightly different from that used when creating objects of a class.Array elements are numbered starting with 0 and ending with 1 less than the length of the array. If
a
is an array,a[i]
is an indexed variable of the array. The indexi
must have a value greater than or equal to 0 and strictly less thana.length
, the array’s length. Ifi
has any other value when you run your program, an array index out-of-bounds error will occur, causing an error message.When an indexed variable is used as an argument to a method, it is treated just like any other argument whose data ...
Get Java: An Introduction to Problem Solving and Programming, 8th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.