Member Avatar for iamthwee

Ok,

I've been looking through some of the older threads and noticed some bad things regarding vectors.

So what's the deal. Are they worth using in java or should I avoid them like the plague? And if I should, what should I be using instead?

The same questions applies to the StringTokeniser container.

ThanQ.

Recommended Answers

All 8 Replies

Vectors shouldn't be used, because ArrayLists are simply better ;)

StringTokenizer isn't that bad, but I think the newer version is called StringBuilder... I could be wrong about that one.

Vector is an old legacy class that's been replaced by far more efficient mechanisms.
Its main problem is its poor performance, using ArrayList can under circumstances give you an order of magnitude higher speed.

StringTokenizer is similar. Use the split() method (for example, there are other mechanisms depending on what you are trying to achieve, like indexOf() and substring()) on String instead.

StringTokenizer isn't that bad, but I think the newer version is called StringBuilder... I could be wrong about that one.

StringTokenizer has a better version in String.split()
StringBuilder is an enhanced StringBuffer. :-|

StringBuilder is an enhanced StringBuffer.

I was close.

Quite close! :rolleyes: ;)

yeah, both have String in them ;)

Member Avatar for iamthwee

How long is a piece of String?

;)

How long is a piece of String?

;)

That depends on the scissors. :p

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.