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 is collection sort in java?
What is an example of procedure?
Is java pass by value or pass by reference?
What is a finally block?
What is skeleton and stub?
I want to print “hello” even before main is executed. How will you acheive that?
Tell me about your ability to work under pressure
How many types of flags are there?
Can extern variables be initialized?
write a program that list all permutations of ABCDEF in which A appears before B?
Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?
What is encapsulation in java?
what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread
How does multithreading take place on a computer with a single cpu in java programming?
What about instanceof operator in java?