Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
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 | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| An ArrayList and a Vector | FantaGuy | Java | 5 | 03-19-2009 12:34 PM |
| what is the use of Beaninfo class and introspector class in java beans? | anveth | Java | 0 | 11-24-2008 01:36 AM |
| Vector data should be placed in Drop Down box | upenderreddy | JSP | 1 | 07-31-2007 07:17 AM |
| Why we say arraylist is not synchronized where as vector are | Geek_Guest | Java | 1 | 06-20-2007 12:50 PM |
| Web Service method returns a vector of objects | ssumitha | ASP.NET | 1 | 12-14-2006 08:25 AM |