How does Vector implement synchronization?
Answer Posted / swamy
import java.util.Vector;
public class VectorExample {
public static void main(String[] args) {
Vector<String> vc=new Vector<String>();
// <E> Element type of Vector e.g. String, Integer, Object ...
// add vector elements
vc.add("Vector Element 1");
vc.add("Vector Element 2");
vc.add("Vector Element 3");
vc.add("Vector Element 4");
vc.add("Vector Element 5");
// add vector element at index
vc.add(3, "Element at fix position");
// vc.size() inform number of elements in Vector
System.out.println("Vector Size :"+vc.size());
// get elements of Vector
for(int i=0;i<vc.size();i++)
{
System.out.println("Vector Element "+i+" :"+vc.get(i));
}
}
}
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What do you mean by JVM?
What is finally and finalize in java?
How do you reverse sort a list in java?
Differentiate jar and war files?
Is java jre still free?
Is null a keyword in java?
What is the difference between path and classpath variables?
What is bean? Where it can be used?
Should database connections be singleton?
What is thread count in java?
What are the steps involved to create a bean?
How do you create a first line indent?
Does java initialize arrays to zero?
How does indexof work?
Name container classes in java programming?