This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
theoritcally it mentions that we should use a Vector when we are bothered about Thread Safety , but generally each Thread will have its own copy of data so typically while fetching data from database in APplications we generally store it in a ArrayList , which is very common .
Could anybody tell me a scenario where we should compulsarily use a vector only .
Personally, I would say you should never use the Vector. There are multiple reasons why, and if you care to find them you can search. But for the sake of your question there are replacements, such as a synchronized list returned from Collections.synchronizedList(). So instead of reading your question as 'When should we use a Vector?' I will answer it as 'When should we use a Synchronized List?'
You use the synchronized list when you share the SAME List instance across multiple threads. If you have one List per Thread, then use ArrayList. But if you have a single pool of data which multiple Threads need to access, then you need to synchronize access to the data, and so a Synchronized List gets you part way there (you still need to do some external synchronization when doing multiple-access operations like swapping values, iterating, or checking if a value is there-then getting it if it is).