🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

4 total messages Started by BH Tue, 03 Jul 2001 21:20
Is Vector class deprecated?
#542
Author: BH
Date: Tue, 03 Jul 2001 21:20
7 lines
1365 bytes
I'm using Vector in the application I'm developing now but a colleague told
me that Vector is deprecated in Java 2.  The java doc doesn't mention
whether it's deprecated or not.  I just want to make sure.  Could someone
help?

Thanks a lot
Bob
Re: Is Vector class deprecated?
#544
Author: Jason Spashett
Date: Wed, 04 Jul 2001 04:49
20 lines
1713 bytes
I dount it will be depreciated ever since it is a well known
stucture/algorithm. It may however, be superceeded by other data stuctures,
but I am sure it wont become obsolete.

"BH" <bobcat99@usa.net> wrote in message
news:dyp07.64$c3.37126@newsrump.sjc.telocity.net...
> I'm using Vector in the application I'm developing now but a colleague
told
> me that Vector is deprecated in Java 2.  The java doc doesn't mention
> whether it's deprecated or not.  I just want to make sure.  Could someone
> help?
>
> Thanks a lot
> Bob
>
>
>
>
>
>
Re: Is Vector class deprecated?
#545
Author: Pete
Date: Sun, 08 Jul 2001 23:56
23 lines
1695 bytes
"BH" <bobcat99@usa.net> wrote in message
news:dyp07.64$c3.37126@newsrump.sjc.telocity.net...
> I'm using Vector in the application I'm developing now but a colleague
told
> me that Vector is deprecated in Java 2.  The java doc doesn't mention
> whether it's deprecated or not.  I just want to make sure.  Could someone
> help?
>
> Thanks a lot
> Bob
>
>
>
>
>
>

There may be some deprecated API inside of Vector, but the class as a whole
is not. I doubt it
will be.

- pete
Re: Is Vector class deprecated?
#546
Author: Charles Hasegawa
Date: Wed, 11 Jul 2001 04:49
51 lines
3440 bytes
No Vector is not depreciated, however unless you are doing a threaded
application where multiple threads accessing the Vector may be dangerous,
you shouldn't use the Vector class.

What your colleague meant was that with Java 1.2, the re-did the API a
little (Vector wasn't very well written in the first place - its methods,
pre Java 1.2, are mostly final and synchronized). The BETTER class to use is
from the Collection framework (to which Vector now belongs). There are four
major classes that can be used to dynamically store any number of Objects.

java.util.ArrayList : Basically just like Vector, except that the methods
aren't final and synchronized. Great if you need to loop through the list a
lot as it is basically an array. Bad if you need to insert into the list, as
items in the list have to be copied to accomidate the insert.

java.util.LinkedList : If you don't know what a linked list is, go back to
school. This class is good if you do a lot of insert and delete operations.
Slower to find items not at the begining of the list (if you have 1000 items
and want the 900th item, you have to 'walk' through 899 links instead of
just getting the object you want.

java.util.TreeSet : Two important features - sorted, and its a set (no
duplicates allowed). This means your objects need to have .equals() defined
to make sence (for custom classes) and the need to implement the comparable
interface. Use when sorting and searching are priorities.

java.util.HashSet : Again this is a set, so uniqueness is a feature. The
biggest feature is order 1 lookup. Here your Objects need to implement
.equals() and .hashcode() properly.

Most likely, since you were using Vector, you should use instances of
ArrayList, but using them as Collection objects will let you make the change
to another specific type, if your needs change.


"BH" <bobcat99@usa.net> wrote in message
news:dyp07.64$c3.37126@newsrump.sjc.telocity.net...
> I'm using Vector in the application I'm developing now but a colleague
told
> me that Vector is deprecated in Java 2.  The java doc doesn't mention
> whether it's deprecated or not.  I just want to make sure.  Could someone
> help?
>
> Thanks a lot
> Bob
>
>
>
>
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads