🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java
Article #546

Re: Is Vector class deprecated?

#546
From: 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
>
>
>
>
>
>
Technical Details
Message-ID: <lVQ27.180298$L4.22200369@news1.rdc1.az.home.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.az.home.com.POSTED!not-for-mail
References: <dyp07.64$c3.37126@newsrump.sjc.telocity.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5d71,5f0657de2b94be64
X-Google-Attributes: gidf5d71,public
X-Google-Thread: fbe9c,5f0657de2b94be64
X-Google-Attributes: gidfbe9c,public
X-Google-ArrivalTime: 2001-07-10 21:49:23 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.az.home.com.POSTED!not-for-mail
From: "Charles Hasegawa" <CurveWrecker@home.com>
Newsgroups: comp.lang.java,borland.public.jbuilder.java
References: <dyp07.64$c3.37126@newsrump.sjc.telocity.net>
Subject: Re: Is Vector class deprecated?
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Message-ID: <lVQ27.180298$L4.22200369@news1.rdc1.az.home.com>
Date: Wed, 11 Jul 2001 04:49:21 GMT
NNTP-Posting-Host: 24.20.223.48
X-Complaints-To: abuse@home.net
X-Trace: news1.rdc1.az.home.com 994826961 24.20.223.48 (Tue, 10 Jul 2001 21:49:21 PDT)
NNTP-Posting-Date: Tue, 10 Jul 2001 21:49:21 PDT
Organization: Excite@Home - The Leader in Broadband http://home.com/faster