© Doug Winnie 2021
D. WinnieEssential Java for AP CompScihttps://doi.org/10.1007/978-1-4842-6183-5_44

44. Make Collections Using Arrays

Doug Winnie1  
(1)
Mission Hills, KS, USA
 

Arrays are collections of identically typed objects that you can refer to as a single name. You can also access the individual items within them using bracket notation and using index numbers.

Creating an Array with Values

Arrays are defined just like any other variable. You need to define the type of values that will be contained within the array and use a pair of brackets to indicate that you are creating an array instead of a single value.

There are two ways you can create an array. You can create an array from a set of values, or you can define an empty array by declaring ...

Get Essential Java for AP CompSci: From Programming to Computer Science 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.