if you use an index that' less than or greater than the size of the array less you'll get the array index out of bounds runtime error initialization unless you specify otherwisean array of integers is automatically initialized to when it' created unlike ++this is true even of arrays defined within method (functionsay you create an array of objects like thisautodata[cararray new autodata[ ]until the array elements are given explicit valuesthey contain the special null object if you attempt to access an array element that contains nullyou'll get the runtime error null pointer assignment the moral is to make sure you assign something to an element before attempting to access it you can initialize an array of primitive type to something besides using this syntaxint[intarray }perhaps surprisinglythis single statement takes the place of both the reference declaration and the use of new to create the array the numbers within the curly brackets are called the initialization list the size of the array is determined by the number of values in this list an array example let' look at some example programs that show how an array can be used we'll start with an old-fashioned procedural version and then show the equivalent objectoriented approach listing shows the old-fashioned versioncalled array java listing the array java program /array java /demonstrates java arrays /to run this programc>java arrayapp ///////////////////////////////////////////////////////////////class arrayapp public static void main(string[argslong[arr/reference to array arr new long[ ]/make array int nelems /number of items