Array Syntax
Points to keep in Mind
Array List API
list.add (10) // Appends the specified element to the end of this list. Returns boolean
list.add(3, 10) //Inserts at index 3 Shifts current and subsequent elements to the right (adds one to their indices)int indx = list.indexOf(10) //index of the first occurrence of the element in the list, or -1 if this list does not contain the element.
int data = list.get(3) //Returns the element at the specified position in this list.
ListIterator listIterator() //Bi directional iterator
list.set(3, 10) //Replaces the element at the specified position .Returns the previous element
list.remove(3) //Removes the element at the specified position in this list.
list.remove(10) //Removes the first occurrence of the specified element from this list, if it is present.
1D Arrays
2D Array using primitive arrays
A Rectangular 2D array has different no. of Rows and Columns (eg: 6X7)
In both cases, the row and column count is
int row = arr.length;
int col = arr[0].length;
The Skewed 2D array need not have the same number of Columns each Row.
2D ArrayList
Square Matrix using Arraylist with a focus on Iteration
Row count is equal to the size of the entire List
row = list.size();
Column count is individual sublist size
col = list.get(i).size();