PDA

View Full Version : Java Vector - Help


AndsomeAndy
11-03-2008, 02:13 PM
Hi there,

I was wondering if any of the Gurus here could explain the following:

I have read quite a few old O'reilly Java books that my friend lent to me.

I was wondering why the way of creating a Vector object has changed?

Can anyone explain this to me... Probably a basic question but I was just wondering, cause it caused a problem with one of my Apps.

Andy :thumbsup:

Fou-Lu
11-03-2008, 04:14 PM
OMG it changed? When?
The only way I've known is a standard constructing. I think it may be overloaded, but I've never used anything but the default constructor. That and generics which started in version 5.
The only difference is generics *can* take an object type:

Vector<String> stringVector = new Vector<String>();
// Versus old:
Vector stringVector = new Vector();

The generics really help though, now I don't need to typecast my result since I know it will be a string (the first one can only hold string, nothing else).

Is this what you mean by the change, or is there another type of change I've missed out on? Generics are quite frequent in java classes now, most of the collections allow them as well as comparable interfaces. Generics are the single best feature. Ever. After pointers. :P.


And structs.