Logo

Home Basics Structures Collections Constructors and Methods Classes

Collections:

Type
Description
Example
Array
Is a collection class that has a set number of elements that can go into the list.

private int[] numbers; - sets an Array of ints
numbers = new int[100]; -initiallizes the Array with 100 elements

numbers[10] = 8; -Sets index 10 as the number 8 .

ArrayList
Is a collection class that does not have a set limit of how many items can go into the list.

import java.util.ArrayList; -imports the ArrayList class
import java.util.Iterator; -imports the iterator that is used in while loops for the class.

private ArrayList <Account> account; -sets up an ArrayList
account = new ArrayList <Account>(); - initializes it



LinkedList
A collection class where the items in the list are linked with pointers that points to the next or previous item in the list.

private LinkedList llist; - declares llist is a LinkedList Object
llist = new LinkedList; - initializes the list.

 

Copyright 2009 Kimberly Pardue
Last updated: March 18, 2009

Home | Basics |Structures |Collections |Con/Meth |Classes