Click to See Complete Forum and Search --> : Vectors
MethadoneBoy
Feb 18th, 2002, 11:16 AM
Is there a Vector package in Java like there is in C++? I'm aware that C++ uses vectors as arrays and I remember someone on these forums saying to me that the Vector class in Java implements something similar to the Dynamic Array function in VB. This true?
Dillinger4
Feb 18th, 2002, 11:54 AM
The java.util.Vector class is declared
synchronized which means that the
integrity of the data it holds will not be
jeopardized by concurrent access.
java.util.ArrayList offers slightly better
performance as it has no synchronization. :)
Dillinger4
Feb 19th, 2002, 01:45 PM
Just to add....... You could add synchronization to a class that
is not synchronized by using some static factory methods defined within the Collections class (not to be confused with the Collections interface). You could essentially use an ArrayList and get the same thread saftey that the Vector and Hashtable classes provide using this approach. :)
List synclist = Collections.synchronizedList(somelist);
synchronized(synclist){
for(Iterator i = synclist.iterator();i.hasNext();)
doSomthing(i.next())
}
Mrs Kensington
Feb 20th, 2002, 03:48 AM
Yes its true! its in java.util.Vector.
MethadoneBoy
Feb 20th, 2002, 04:28 AM
And here's me after writing a Dynamic Array class. Sigh :)
billrogers
Feb 20th, 2002, 03:31 PM
lol, that is they way it usually happens. It is good for you, that way you probably learned in the process. I try to do that from time to time, rewrite things that already exist just so my level of skill stays high enough.
Dillinger4
Feb 21st, 2002, 12:11 AM
Posted by billrogers
lol, that is they way it usually happens. It is good for you, that way you probably learned in the process. I try to do that from time to time, rewrite things that already exist just so my level of skill stays high enough.
I do the same thing also when i get bored or im in the middle of trying to figure out my next project. Youre right it does keep you sharp. :D
MethadoneBoy
Feb 21st, 2002, 04:58 AM
Yeah, I'm actually glad I wrote the artificial Dynamic Array class - even if it is a little cumbersome sometimes. :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.