ArrayList Vector

Definition

Extensible list which can collect any objects. The difference between ArrayList and Vector is, that a ArrayList is not synchronized, but therefore faster. In most cases a ArrayList will be used.

Since Java 5 you can and should define the type of object the list contains. The advantages are, that you do not need to cast when retrieving an object and the compiler can early show errors.

Example

List<User> list = new ArrayList<User>(); list.add(new User()); list.add(new User()); for (User user : list) System.out.println(user.toString()); for (int i = 0; i < list.size(); i++) System.out.println(list.get(i).toString());

Johannes Hammoud ArrayList Vector 06.02.2006

I Coding : Community about Java programing

Language German+-

Java JSF JavaScript HTML CSS NetBeans GlassFish MySQL

Imprint

Visits
5745984
Today
66