The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Tony Morris
Java Q&A (FAQ, Trivia)
Originally posted by Sameera Abeysinghe:
Ok so I create a vector object with
initialCapacity= 10 and capacityIncrement = 1
I use vector.add() to add elements
How can I access the elemnt?
By vector.get()
Will it remove the element from that vector???
And finals when I use any methods in the vector since it is synchronize I don’t have to bother about putting notify of notifyall or synchronize or what ever
Is it???
How about if I use vector.toArray() in each of my 10 threads and the do this operation using that object array
Is it ok ???
Originally posted by Tony Morris:
Don't use a Vector - this is a red herring.
http://jqa.tmorris.net/GetQAndA.action?qids=53&showAnswers=true
You likely want a java.util.ArrayList.
http://java.sun.com/docs/books/tutorial/collections/
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
I disagree. ArrayList is the way to go if you don't need any synchronization. If you do, there are only two options:
1) Vector
2) call Collections.synchronizedList(List l) with an ArrayList
There is no emoticon for what I am feeling!
Originally posted by Rob Spoor:
I disagree. ArrayList is the way to go if you don't need any synchronization. If you do, there are only two options:
1) Vector
2) call Collections.synchronizedList(List l) with an ArrayList
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |