View RSS Feed

Recent Blogs Posts

  1. Vector Capacity

    by , 11-13-2011 at 12:48 PM (My Java Tips)
    In this post, I will talk about the performance issues related to vector capacity. I have noticed, that normally developers don’t care about the performance issues and declare the vector as:

    Java Code:
    Vector vector = new Vector();

    Newly created vector has no element in it so its size is 0 but its capacity is 10 by default. So if you don’t specify the capacity of the vector (and call the default constructor), its capacity will be 10. Capacity of the vector is the ...
    Tags: capacity, vector Add / Edit Tags
  2. Using Vectors

    by , 11-08-2011 at 07:26 PM (My Java Tips)
    When using arrays, you have to give their size at declaration. So arrays do not expand dynamically. Vectors expand automatically when data is added to them. Vector class is included in java.util package. Vectors are used to store Objects.

    Vector is thread safe. It means Vectors are synchronized, means you can use Vectors even if your object might be shared by two or more threads at a same time. This makes Vector slower than ArrayList which is not thread safe.

    Following ...