What is an Enumeration

An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It is a construct which collection classes return when you request a collection of all the objects stored in the collection. It allows sequential access to all the elements stored in the collection. In Core Java, … Read more

Why Java Vector Class is Considered Obsolete or Unofficially Deprecated? or Why should I always use ArrayList over Vector

You should use ArrayList over Vector because you should default to non-synchronized access. Vector synchronizes each individual method. That’s almost never what you want to do. Generally you want to synchronize a whole sequence of operations. Synchronizing individual operations is both less safe (if you iterate over a Vector, for instance, you still need to … Read more

What is the Difference Between Enumeration and Iterator Interface

Enumeration and Iterator are the interface available in java.util package. The functionality of Enumeration interface is duplicated by the Iterator interface. New implementations should consider using Iterator in preference to Enumeration. Iterators differ from enumerations in following ways: Enumeration contains 2 methods namely hasMoreElements() & nextElement() whereas Iterator contains three methods namely hasNext(), next(),remove(). Iterator … Read more

Difference between Vector and ArrayList? What is the Vector Class

Vector & ArrayList both classes are implemented using dynamically resizable arrays, providing fast random access and fast traversal. ArrayList and Vector class both implement the List interface. Both the classes are member of Java collection framework, therefore from an API perspective, these two classes are very similar. However, there are still some major differences between … Read more

Where will you use Hashtable and where will you use HashMap

  of possible future changes. In Java, both Hashtable and HashMap are implementations of the Map interface, and they are used to store key-value pairs. However, there are some differences between the two: Thread Safety: Hashtable is synchronized, which means it is thread-safe. Multiple threads can safely access a Hashtable concurrently. HashMap is not synchronized … Read more