7 Arrays

 

Exam objectives covered in this chapter

What you need to know

[5.1] Declare, instantiate, initialize, and use a one-dimensional array.

How to declare, instantiate, and initialize one-dimensional arrays using single and multiple steps.

The do’s and don’ts of each of these steps.

[5.2] Declare, instantiate, initialize, and use a multidimensional array.

How to declare, instantiate, and initialize multidimensional arrays using single and multiple steps, with do’s and don’ts for each of these steps.

Accessing elements in asymmetric multidimensional arrays.

In the Java SE 11 Programmer I exam, you’ll be asked many questions about arrays. To prepare you for such questions, we’ll cover the following in this chapter:

  • What are one-dimensional and multidimensional arrays
  • Creating arrays in single or multiple steps
  • Declaring, allocating, and initialization of an array
  • Combining array declaration, allocation, and initialization

Let’s get started.

7.1      Arrays

[5.1] Declare, instantiate, initialize and use a one-dimensional array

[5.2] Declare, instantiate, initialize and use two-dimensional array

In this section, I’ll cover declaration, allocation, and initialization of one-dimensional and multidimensional arrays. You’ll get to know about the differences between arrays of primitive data types and arrays of objects.

7.2      Array declaration

7.3      Array allocation

7.4      Array initialization

7.5      Combining array declaration, allocation, and initialization

7.6      Summary

7.7      Sample exam questions

7.8      Answers to sample exam questions