5

Array Data Structures

Array Data Structures Arrays

Contents

  • Arrays as simple structures
  • Some examples and uses
  • Creating arrays dynamically at runtime
5.1 INTRODUCTION

In Chapter 2, we discussed issues that arise if a list of items is represented using separate discrete variables. In this chapter, we see how arrays deal with these issues. We show how items are stored and manipulated as an array, and build a simple example application.

5.2 WHAT IS AN ARRAY?

Consider the eight integers that we touched on in Chapter 2, Section 2.4. It is not efficient to declare eight separate variables with discrete identifiers; instead, make the following declaration:

  int numbers[] ...

Get Introducing Data Structures with Java 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.