0% found this document useful (0 votes)
2 views3 pages

Experiment No 14 Java

java

Uploaded by

jsamiksha051
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Experiment No 14 Java

java

Uploaded by

jsamiksha051
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiment no 14 : Develop program for implementation of vectors in java

Q1) Write a program to insert different elements in the vector and display them.

import java.util.*;

class VectEx {

public static void main(String args[])

Vector v = new Vector();

Integer i=new Integer(122);

Float f=new Float(123.90f);

Double d=new Double(56712.5456);

Long l=new Long(987665412);

String str=new String("hello,java");

v.addElement(i);

v.addElement(f);

v.addElement(d);

v.addElement(l);

v.addElement(str);

System.out.println("content's of vector are:"+v);

Output:
Q2) write a program to use different methods of vector class.

import java.util.*;

public class VectorEx {

public static void main(String[] args) {

Vector v = new Vector();

Integer i=new Integer(10);

Integer i1=new Integer(20);

Float f =new Float(123.345);

Float f1 =new Float(12399.7068);

String str=new String("SAMIKSHA");

String str1=new String("JADHAV");

Long l=new Long(123456789);

v.addElement(i);

v.addElement(i1);

v.addElement(f);

v.addElement(f1);

v.addElement(str);

v.addElement(str1);

v.addElement(l);

System.out.println("VECTOR CONTENT ARE:"+v);

System.out.println("element at 3rd postion:"+v.elementAt(3));

System.out.println("size of vector:"+v.size());

System.out.println("remove element through object:"+v.removeElement(i));

System.out.println(v);

System.out.println("removing all element from vector!!!!");

v.removeAllElements();
System.out.println("AFTER PERFORMING OPERATION VECTOR CONTENTS ARE:"+v);

Output:

You might also like