Java Collection Classes
Java Collection Classes
Com379PT
[email protected]
Collection Classes
Implementations – Implementations of
the collection interfaces.
Array
List
Vector
ArrayList
Queue
Associative Array
Hashtable
+ More
ArrayList – Collection example
public class Student
{
private String name;
aStudent = (Student)studentList.get(0);
Iterating through the list
Iterator it = list.iterator();
while (it.hasNext())
{
Student aStudent = (Student)it.next();
System.out.println(aStudent.toString());
}
Why use collections?
It reduces programming effort?
Provides useful data structures
Allows you to concentrate in the
working of the code
Allows interoperability among
unrelated API’s
If your communication API has a
collection of IP’s and my GUI API
displays in TABS IP’s then they can
work together even though they were
written separately