jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes Can vectors only hold objects? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can vectors only hold objects?" Watch "Can vectors only hold objects?" New topic

Can vectors only hold objects?

Willie Toma
Ranch Hand

Joined: May 11, 2001
Posts: 78
Is it true that Vectors can only hold objects?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

If you want it to hold 'primitive' types, like integers, floats, doubles, etc...

You can wrap these values in their respective Object types and store those in the Vector. Getting them out again is a bit trickier.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Which means that if you want to put a primitive in one, then you need to put it in a wrapper object. So you would put a double in a Double object etc. In which case, vectors can hold anything (sort of).

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link: http://aspose.com/file-tools
subject: Can vectors only hold objects?
Similar Threads
Array vs Vector
Vector Question!!
Difference b/w Array, arraylist, vector
Vector Question
problem in vector