Filed under: Class Notes, Java | Tags: CCAC, CIT111, Class Notes, Java, java arrays, loops, methods, programming
–Primitive variables are designs to hold only one value at a time
–allows to create collection of like indexed values
–can store any type of data but only one type at a time
–List of data elements
–An array is an object so it needs to be referenced. Then create array and assign address
intnameofarray=new int [INTEGER VALUE]
Integer value can be a variable, a constant etc but always must be INT.
–Whatever data type is stored in the array determines how it is initialized. If it’s created as an INT all values start at 0.
–may be of any type (floats, car, long, double etc)
ARRAY SIZE: must be a non negative number. It may be a literal, a constant, or avariable
ex: final int ARRAY_SIZE=6
int numbers=new int[ARRAY_SIZE]
–Once created the size is fixed and cannot change!!
USING INDEX VALUES
–The first element is ALWAYS INDEX 0. The last element in the array is always the size or length -1
In an array with 6 indexes. The first one is index0, the last one is index5
Calling an index:
arrayname[indexnumber]= new value //assigning variables to be held in the index
An array is accessed by:
–The reference name
–the subscript  which declares what to access
Can be treated like any other variable of the same type.