Array List
Array List
Array List
By
Arvind Kumar
Asst. Professor, LPU
Introduction
• Standard Java arrays are of a fixed length.
boolean addAll(Collection c )
• Appends all of the elements in the specified collection to the end of
this list.
• Throws NullPointerException if the specified collection is null.
Object clone()
• Returns a shallow copy of this ArrayList.
int size()
• Returns the number of elements in the list.
boolean contains(Object o)
• Returns true if this list contains the specified element.
int indexOf(Object o)
• Returns the index in this list of the first occurrence of the specified
element, or -1 if the List does not contain the element.
int lastIndexOf(Object o)
• Returns the index in this list of the last occurrence of the specified
element, or -1.
void ensureCapacity(int minCapacity)
• Increases the capacity of this ArrayList instance, if necessary,
to ensure that it can hold at least the number of elements
specified by the minimum capacity argument.
Let’s Do It
• Create a class Student having attributes name, fatherName,
rollNo, section, college and address. Write a menu driven
program to store and display the records of any number of
Students.