Geeks Talk

Prepare for your Next Interview




Use of vector class

This is a discussion on Use of vector class within the Java forums, part of the Software Development category; plz tell me the use of vector & how is diff from array...


Go Back   Geeks Talk > Software Development > Java

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-29-2008
Junior Member
 
Join Date: Dec 2008
Location: delhi
Posts: 8
Thanks: 3
Thanked 1 Time in 1 Post
soniyaparjapat is on a distinguished road
Unhappy Use of vector class

plz
tell me the use of vector
& how is diff from array
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-31-2008
Junior Member
 
Join Date: Dec 2008
Location: hyderabad
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
sancooljit is on a distinguished road
Re: Use of vector class

define a variable of type Vector, and call the vector constructor.

Vector myVector = new Vector ();

OR
myVector = new Vector(50);

dynamically increase the size of the vector, bt in case of array the size is fixed.

2] Implement the Enumeration interface which makes traversing the contents of a Vector extremely easy.
ex
for (Enumeration e = myVector.elements(); e.hasMoreElements()
{
String myString = (String) e.nextElement();
System.out.println(myString);
}
3] Arrays in Java are static lists declared to store a certain number of a certain kind of variables.
Vector in java are lists declared to store any number of nay kind of variables.
Reply With Quote
  #3 (permalink)  
Old 01-05-2009
Junior Member
 
Join Date: May 2007
Location: Coimbatore
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Akilan Paul is on a distinguished road
Re: Use of vector class

vector is a synchronized data structure
array is unsynchronized data structure
main difference is synchronized data structure performance is low compare with unsynchronized one.
when ever you feel a block of code is accessed by morethan one thread that time you go for synchronized data structures (i.e is thread safe)
Reply With Quote
Reply

  Geeks Talk > Software Development > Java


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
An ArrayList and a Vector FantaGuy Java 5 03-19-2009 11:34 AM
what is the use of Beaninfo class and introspector class in java beans? anveth Java 0 11-24-2008 12:36 AM
Vector data should be placed in Drop Down box upenderreddy JSP 1 07-31-2007 06:17 AM
Why we say arraylist is not synchronized where as vector are Geek_Guest Java 1 06-20-2007 11:50 AM
Web Service method returns a vector of objects ssumitha ASP.NET 1 12-14-2006 07:25 AM


All times are GMT -4. The time now is 09:11 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved