aspose file tools*
The moose likes Beginning Java and the fly likes Vector or Array List which one is better for WebApplication? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Vector or Array List which one is better for WebApplication?" Watch "Vector or Array List which one is better for WebApplication?" New topic
Author

Vector or Array List which one is better for WebApplication?

khalid ahmed
Greenhorn

Joined: Nov 19, 2008
Posts: 17
Dear all,
I am doing a webapplication with Oracle as backend.Earlier in a differnet applicaiton i used vector but it takes sometime to retrieve the db values .
i read in internet like below

1.Vector and Arraylist are grownable or shinkable where are array is not.
2.Vector and Arraylist are implemented from List interface where as array is a primitive data type
3.Vector is Synchrnized where as arraylist is not
4.For best performance better to use arraylist than vector

and i go through the below link

http://www.javaworld.com/javaworld/javaqa/2001-06/03-qa-0622-vector.html

i am confused which one i should use for webapplication.
Taariq San
Ranch Hand

Joined: Nov 20, 2007
Posts: 192
Vector is like the red-headed stepchild in the java household. ArrayList for the win!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39435
    
  28
Welcome to JavaRanch

I hope you understood Taariq San's metaphor!

You need to be very careful about what they say on the internet. ArrayList is a class which you can make objects from, but you mustn't confuse it with an array.

If you read anywhere that an array is a primitive data type in Java, that is mistaken. An array is an object in its own right.
They are correct if they mean that arrays can contain primitives and ArrayLists can't (but you can put primitives into ArrayLists and have them auto-boxed into reference types).
They are also correct that ArrayList implements the List<E> interface, but so does Vector.

If you read about Vector, ArrayList and List Implementations, you find out what to do to synchronise an ArrayList, and you find out that Taariq's recommendation appears to be correct.
 
Don't get me started about those stupid light bulbs.
 
subject: Vector or Array List which one is better for WebApplication?