O'Reilly logo

Java All-in-One For Dummies, 5th Edition by Doug Lowe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2

Using Arrays

IN THIS CHAPTER

check Working with basic one-dimensional arrays

check Using array initializers to set the initial values of an array

check Using for loops with arrays

check Working with two-dimensional arrays

check Working with the Arrays class

I could use a raise….

Oh, arrays. Sorry.

Arrays are an important aspect of any programming language, and Java is no exception. In this chapter, you discover just about everything you need to know about using arrays. I cover run-of-the-mill one-dimensional arrays; multidimensional arrays; and two classes that are used to work with arrays, named Array and Arrays.

Understanding Arrays

An array is a set of variables that is referenced by using a single variable name combined with an index number. Each item of an array is called an element. All the elements in an array must be of the same type. Thus the array itself has a type that specifies what kind of elements it can contain. An int array can contain int values, for example, and a String array can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required