7 A. Write a java program to implement the vectors.
Program :
import java.util.Vector;
class Pract7a
{
public static void main(String args[])
{
Vector<String> v=new Vector<String>();
v.add("Red");
v.add("Green");
v.add("Blue");
System.out.println("Vector Elements are:-"+v);
v.add(2,"Yellow");
System.out.println("After Adding Element at second position:-"+v);
System.out.println("Element at third position:-"+v.get(3));
System.out.println("First Element:-"+v.firstElement());
System.out.println("Last Element:-"+v.lastElement());
System.out.println("Is this vector empty?"+v.isEmpty());
}
}
Public void static (the journey begins);
ReplyDelete