Archives for 

List

Classes that implements the List interface directly or indirectly were described in this category

Vector in java

Vector is a member in Collections frame work of Java  .It implements the List interface. It is a legacy class in java.Vector was in Java in the earlier versions itself.

Vector & ArrayList

Vector is almost same as that of ArrayList.Vector also based on index values for each items. But the methods in vector class are thread safe. This gives a little performance  fall.Vector ,like ArrayList  implements the interface RandomAccess  .So the only difference between Vector and ArrayList is the thread safety of its methods.

Now let us see an example code and its output. It adds few string values to the vector .Displaying those values , then removing the strings.

Output

Displaying contents of vector

Item = dog

Item = cat

Item = cow

Item = elephant

Item = sheep

Removing contents of list

Contents removed  ,now size of vector = 0

See Related Discussions

Collections in Java

ArrayList

LinkedList

HashMap

HashSet