Home Technology Subscribe to RSS

What Are The Differences Between Arraylist And Vector? Give Me One Example Of Each.

Answer Question

1 Answer - Sort by: Date | Rating

    Arraylist and vector are very similar to each other. They are fundamentally arrays that are growable and lets you access the elements in it through indices.

    Arraylist is a later addition to Java collection framework. It was added with the version 1.2. On the contrary, the object 'Vector' has been present since the first version of Java development kit. The List interface was later retrofitted into Vector.

    The main difference between the two is perhaps that vectors are synchronized while Arraylist is not and hence they are not thread-safe while vectors are. This will affect the performance and hence if you don't need to be thread safe, please use Arraylist for more efficiency.

    Another difference is that Vector has a default size of 10 while Arraylist has no such default size and it also does not define an increment size, it is static where we can't change the size of the array. On the contrary vector is dynamic and its size can increase or decrease per the storage required by the program.
    0 0

    Rajeshshri1982  

    answered 3 years ago

      More

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International