0% found this document useful (0 votes)
13 views2 pages

PR 5

The document presents a Java programming experiment focused on using arrays and vectors. It includes a sample program demonstrating the creation and manipulation of a Vector, showcasing its initial capacity and size, adding elements, checking for the presence of an element, and removing elements. The output of various operations on the Vector is also displayed.

Uploaded by

saniyakhade04560
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)
13 views2 pages

PR 5

The document presents a Java programming experiment focused on using arrays and vectors. It includes a sample program demonstrating the creation and manipulation of a Vector, showcasing its initial capacity and size, adding elements, checking for the presence of an element, and removing elements. The output of various operations on the Vector is also displayed.

Uploaded by

saniyakhade04560
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/ 2

Name : Kale Bhagyashri Bajirao

Roll No: 40 Course Name: Java Programming(314317) Batch : A2

Experiment Name and No: 5: Write programs to demonstrate: Use of Array. Use of Vectors.

PROGRAM OUTPUT
import java.util.*;
class vector
{
public static void main(String
args[])
{
Vector<Integer>v=new
Vector<Integer>();
System.out.println("
initial capacity");

System.out.println(v.capacity());

System.out.println("initial size");

System.out.println(v.size());
v.add(1);
v.add(2);
v.add(3);
v.add(4);
v.add(5);
v.add(1);
v.add(2);
v.add(3);
v.add(4);
v.add(5);
v.add(72);
System.out.println(v);
System.out.println("
after adding element");

System.out.println(v.size());

System.out.println("capacity");

System.out.println(v.capacity());

System.out.println("Contains");
if(v.contains(72))
{
System.out.println("Yes");
}
else
{

System.out.println("No");
}

System.out.println("Print
element at specified index");

System.out.println(v.elementAt(2));

System.out.println("remove
element");

System.out.println(v.remove(0));

System.out.println("remove all
element");

System.out.println(v.removeAll());
}
}

You might also like