ArrayList

ArrayList - ArrayList . <T> get(int index) Returns...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Methods in the ArrayList Class boolean add(<T> element) Adds a new element to the end of the ArrayList ; the return value is always true . void add(int index, <T> element) Inserts a new element into the ArrayList before the position specified by index . <T> remove(int index) Removes the element at the specified position and returns that value. boolean remove(<T> element) Removes the first instance of element , if it appears; returns true if a match is found. void clear() Removes all elements from the ArrayList . int size() Returns the number of elements in the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ArrayList . <T> get(int index) Returns the object at the specified index. <T> set(int index, <T> value) Sets the element at the specified index to the new value and returns the old value. int indexOf(<T> value) Returns the index of the first occurrence of the specified value, or -1 if it does not appear. boolean contains(<T> value) Returns true if the ArrayList contains the specified value. boolean isEmpty() Returns true if the ArrayList contains no elements . Using portions of slides by Eric Roberts...
View Full Document

This note was uploaded on 02/18/2010 for the course CS 106A taught by Professor Sahami,m during the Fall '08 term at Stanford.

Ask a homework question - tutors are online