O'Reilly logo

Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition by Ivor Horton

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

4.5. Summary

You should now be thoroughly familiar with how to create and use arrays. Most people have little trouble dealing with one-dimensional arrays, but arrays of arrays are a bit trickier so try to practice using these.

You have also acquired a good knowledge of what you can do with String objects, as well as StringBuffer and StringBuilder objects. Most operations with these objects are very straightforward and easy to understand. Being able to decide which methods you should apply to the solution of specific problems is a skill that will come with a bit of practice.

The essential points that I have discussed in this chapter are:

  • You use an array to hold multiple values of the same type, identified through a single variable name.

  • You reference an individual element of an array by using an index value of type int. The index value for an array element is the offset of that element from the first element in the array.

  • An array element can be used in the same way as a single variable of the same type.

  • You can obtain the number of elements in an array by using the length member of the array object.

  • An array element can also contain an array, so you can define arrays of arrays, or arrays of arrays of arrays, and so on.

  • A String object stores a fixed character string that cannot be changed. However, you can assign a given String variable to a different String object.

  • You can obtain the number of characters stored in a String object by using the length() method for the object.

  • The String ...

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