One dimensional arrays are arrays that only have a single index involved, so they are a row or a list not a box, table or chart.
You can make a one dimensional array in several ways as shown below:
- datatype[ ] arrayname= new datatype/object[sizeofarray];
- datatype[ ] arrayname= {variableA,variableB, . . };
You can find the size or length of a array by doing arrayName.length, this is like calling a public variable not a method so there are no parenthesis.
You add a element to an array by doing :
arrayName[index] = <what you want to add to the array as long as its type is the same as the arrays>;
One thought on “one dimensional arrays”
Comments are closed.