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 exactly is java?
Can we declare an interface as final?
What is hotjava?
How does the java compiler work?
What is immutability in java?
Which data type is a class in java?
Explain the hierarchy of java exception classes?
Is main is a keyword?
What do you understand by an io stream?
What is a private class in java?
What is bitwise complement?
Explain constructors and types of constructors in java.
What is the difference between checked exception and unchecked exception?
What is string pool in java?
How do you identify if jvm is 32-bit or 64-bit from java program?