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
Can a abstract class be defined without any abstract methods?
Is string passed by reference in java?
What is skeleton and stub? What is the purpose of those?
Explain the available thread states in a high-level?
What is loop in java?
EDS (Electronic Data Systems India Pvt Ltd) at Chennai on 16-12-2006.
What are the different collection views provided by maps?
What is return used for in java?
What is substring in java?
What is a function in programming?
What methods are used to get and set the text label displayed by a button object?
Hi Anyone know the model / questions of the Federal bank sample questions for the post of Specialist Officers - Programmers. Please post if anyone have..
Can we override a variable in java?
What is an inner class in java?
what do you mean by stream pipelining in java 8? Explain