ArrayList methods

posted by: Ms. Martin 21 February 2010 No Comment

Of course, the full ArrayList specification is available with the rest of the Java documentation.  Though I encourage you to explore all of the capabilities of ArrayLists, you will only be responsible for the following methods:

Method name Description
add(value) adds the given value to the end of the list
add(index, value) inserts the given value before the given index
clear() removes all elements
contains(value) returns true if the given element is in the list
get(index) returns the value at the given index
indexOf(value) returns the first index at which the given element appears in the list (or -1 if not found)
lastIndexOf(value) returns the last index at which the given element appears in the list (or -1 if not found)
remove(index) removes and returns value at given index, sliding others back
set(index, value) replaces the element at position index with value and returns the element formerly at the specified position
size() returns the number of elements in the list
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>