1 Reply Latest reply: Jul 30, 2011 12:26 PM by 801560 RSS

    Convert ArrayList to Vector - performance

    801560
      I have a method which needs to return a Vector object. Now, I realize that I dont really need it to be a Vector here and an ArrayList would do the job too since i dont need a synchronized collection. However, due to framework limitations, the return type must be a vector.

      I was wondering if I could improve performance if I add objects to an ArrayList, and convert it into a Vector by doing something like

      List list = new ArrayList();
      list.add(obj1);
      list.add(obj2);
      list.add(obj3);
      ...

      return new Vector(list);


      Or would simply adding objects to a Vector be better than doing the above/