MY mENU


Friday, 10 February 2012

List Vs Vector


List is an interface, while Vector is a concrete implementation ClassList fixes several minor API deficiencies in Vector. Commonly used Vector operations, such as elementAt and setElementAt, have been given much shorter names.

- We can observe the set method, which replaces the Vector method setElementAtreverses the order of the arguments so that they match the corresponding array operation.

Example : Consider the following assignment statement.

gift[5] = "golden rings";

The Vector equivalent is:

gift.setElementAt("golden rings", 5);

The List equivalent is:

gift.set(5, "golden rings");

- The method add(int, E), which replaces insertElementAt(Object, int), also reverses the order of the arguments.

- The three range operations in Vector (indexOf, lastIndexOf, and setSize) have been replaced by a single range-view operation (subList), which is far more powerful and consistent.

No comments:

Post a Comment