Prepare for your Next Interview
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...
|
|||
|
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. ![]() |
|
|||
|
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) |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| 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 |