Vector vs. LinkedList

M

Mike Schilling

Lew said:
I am always learning from this group.

It's actually all part of the same point.

ConcurrentModificationException doesn't mean "two modifications are taking
place concurrently." (Even if it did, that couldn't happen to a Vector or
any other synchronized collection.) It means "the collection has been
modified concurrently with your use of it", and so far as I know it's always
used to indicate that an iterator's view of a collection is out of date.
Like most things in Java, it's not reliable in unsynchronized multithreading
scenarios, but you can see it thrown here:

List list = new ArrayList();
list.add(new Object());
list.add(new Object());
list.add(new Object());
Iterator iter = list.iterator();
list.remove(0);
if (iter.hasNext())
iter.next(); //boom!
 
H

Hal Vaughan

Hal said:
I've read up on Vectors and LinkedLists. Other than slightly different
interfaces, I'm not clear on reasons for using one over the other. Both
can keep growing and can have members inserted or removed as needed.

Is there a reason to use one over the other?

Thanks for all the answers. I've learned a lot more than I suspected.
There were issues involved that I didn't even know about. (Yes, self
taught, which means I've missed a lot along the way.)

Hal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top