Basic concept
ADT indicates for Abstract Data Type.
Arrays are defined as ADT’s because they are capable of holding contiguous elements in the same order. And they permit
access for the specific element via index or position.
They are abstract because they can be String, int or Person
int[] arrA = new int[1]; String[] arrB = new String[1]; Person[] arrC = new Person[3]; // where Person is treated as a defined class
Advantages
- Fast, random access of items or elements.
- Very memory efficient, very little memory is needed other than that needed to store the contents.
Disadvantages
- Slow insertion and deletion of elements
- Array size must be known when the array is created and is fixed (static)
An Array-Based Implementation of the ADT List
Public class ListArrayBased implementsListInterface { private static final int MAX_LIST1 = 50; private Object items1[]; // an array of list items privateint numItems1; // number of items in list publicListArrayBased() { items1 = new Object[MAX_LIST1]; numItems1 = 0; } // end default constructor }