intarray[ /get contents of fourth element of array /insert into the eighth cell remember that in javaas in and ++the first element is numbered so that the indices in an array of elements run from to 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 boundsruntime error this is an improvement on and ++which don' check for out-of-bounds indicesthus causing many program bugs 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 (functionif you create an array of objectslike thisautodata[cararray new autodata[ ]thenuntil they're given explicit valuesthe array elements 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 braces 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 versionand then show the equivalent objectoriented approach listing shows the old-fashioned versioncalled array java listing array java /array java /demonstrates java arrays /to run this programc>java arrayapp import java io */for / ///////////////////////////////////////////////////////////////class arrayapp public static void main(string[argsthrows ioexception int[arr/reference arr new int[ ]/make array int nelems /number of items int /loop counter int searchkey/key of item to search for