<< Chapter < Page | Chapter >> Page > |
Revised: Mon Mar 28 16:20:59 CDT 2016
This page is included in the following Books:
This module takes a preliminary look at arrays and strings. More in-depth discussions will be provided in future modules. For example, you will find a more in-depth discussions of array objects in the followingmodules:
I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the Figuresand Listings while you are reading about them.
The first step
The first step in learning to use a new programming language is usually to learn the foundation concepts such as variables, types,expressions, flow-of-control, arrays, strings, etc. This module concentrates on arrays and strings.
Array and String types
Java provides a type for both arrays and strings from which objects of the specific type can be instantiated. Once instantiated, the methodsbelonging to those types can be called by way of the object.
Arrays and Strings
Java has a true array type and a true String type with protective features to prevent your program from writing outside the memorybounds of the array object or the String object. Arrays and strings are true objects.
Declaring an array
You must declare an array before you can use it. (More properly, you must declare a reference variable to hold a reference to the array object.) In declaring the array, you must provide two important pieces of information:
Different declaration formats
A reference variable capable of holding a reference to an array object can be declared using either format shown in Figure 1 . (I personally prefer the first option because I believe it is more indicative ofthe purpose of the declaration. However, both options produce the same result -- a reference variable capable of storing a reference to an array object.)
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?