13-ArrayList

13-ArrayList - Chapter XIII The List Interface and...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter XIII The List Interface and ArrayList Class Chapter XIII Topics 13.1 Introduction 13.2 What is an Interface? 13.3 The Collection Hierarchy 13.4 Java Collection Classes 13.5 ArrayList Methods 13.6 ArrayList and Primitive Data Types 13.7 ArrayList and Generics 13.8 ArrayList and the Enhanced For Loop 13.9 Summary 13.1 Introduction Chapter XIII The List Interface and ArrayList Class 627
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Most programming languages have one type of array. Frequently it is - like the static array of the previous chapter - both one-dimensional and multi-dimensional. Java has two types of arrays. Java has the static array, shown last chapter, which is constructed with a fixed size that can not be altered during program execution. Additionally, Java has a dynamic array, which does not require a predetermined size at instantiation that can be altered during program execution. The focus of this chapter is on the dynamic array, which is implemented with the ArrayList class. The secondary focus is on the introduction of the List interface. You will see that the dynamic array is very different from the static array and an important goal of this chapter is to clarify when it is best to use a static array and when it is better to use a dynamic array. Java Arrays Java has a static array capable of multi-dimensions. Java has a dynamic array capable of only one dimension. The ArrayList class is used for the dynamic array. 13.2 What is an Interface? Now before we plunge into the details of working with the dynamic ArrayList class we need to take a detour and appreciate the meaning of the word interface . The word interface certainly gets a lot of press, but it is a very good word. In the area of technology you are constantly interfacing. We think of an interface as a means to communicate and access the capability of some object. Just look at a television. In the old days people were forced to walk up to a television and manually turn knobs to select channels and volume. Today we have a remote control that interfaces with the television. Java's interface is not exactly like a television remote control, but there are similarities. You may know absolutely nothing about the technology required to 628 Exposure Java 2009, APCS Edition 08-08-09
Background image of page 2
create a television remote control. Yet, you can discuss the functionality of such a control. You have the ability to state what you desire in a remote control and you can also use a remote control once you are familiar with the functionality of each button on the interface. Imagine the following scenario. A production manager gathers a team of engineers and wants a remote control created. This manager wants the remote control to handle the following features: Power on/off Volume lower/higher Channels up/down Switch between TV/VCR Play/pause/fast-forward/rewind VCR Program VCR The manager is not an engineer. The manager is an administrator who knows what the company wants to produce and sell. Administrators leave the concrete implementations of their abstract ideas to the engineers. The creation of the remote control is like the creation of a new class.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/14/2010 for the course APSC AP taught by Professor Kurt during the Spring '98 term at Wooster.

Page1 / 36

13-ArrayList - Chapter XIII The List Interface and...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online