0% found this document useful (0 votes)
22 views4 pages

Kalpesh 7

This document contains summaries of 3 Java programs: 1) A program implementing the Vector class by adding/removing elements, updating elements, and checking properties like size and empty status. 2) A program implementing the HashMap class by adding key-value pairs, removing elements, and checking properties like size and empty status. 3) A program demonstrating the wrapper classes Integer and Double by converting between primitive types and their corresponding wrapper classes.

Uploaded by

KALPESH BORSE
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)
22 views4 pages

Kalpesh 7

This document contains summaries of 3 Java programs: 1) A program implementing the Vector class by adding/removing elements, updating elements, and checking properties like size and empty status. 2) A program implementing the HashMap class by adding key-value pairs, removing elements, and checking properties like size and empty status. 3) A program demonstrating the wrapper classes Integer and Double by converting between primitive types and their corresponding wrapper classes.

Uploaded by

KALPESH BORSE
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/ 4

JAVA PRACTICAL 2106025

Program 1:-Program for implementing Vector class:-

import java.util.*;

public class vector_1 {


public static void main(String[] args) {

Vector<Integer> vector = new Vector<>(); //2106025

vector.add(1);
vector.add(2);
vector.add(3);
vector.add(4);

System.out.println("Vector: " + vector);

int element = vector.get(2);


System.out.println("Element at index 2: " + element);

vector.set(1, 5);
System.out.println("Updated Vector: " + vector);

vector.removeElement(3);
System.out.println("Vector after removing 3: " + vector);

boolean isEmpty = vector.isEmpty();


System.out.println("Is the Vector empty? " + isEmpty);

int size = vector.size();


System.out.println("Size of the Vector: " + size);
}
}

1
JAVA PRACTICAL 2106025

OUTPUT:-

2
JAVA PRACTICAL 2106025

Program 2:-Program for for implementing Hashmap:-

package vector;
import java.util.*;

public class hashmap {


public static void main(String[] args) //2106025
{
HashMap<Integer,String> map = new HashMap<Integer,String>();

map.put(10,"Kalpesh");
map.put(20,"Pranav");
map.put(30,"Aditya");
map.put(40,"Ram");

System.out.println(map);

map.remove(30);

System.out.println(map);

String name=map.get(10);

System.out.println(name);

boolean a = map.isEmpty();

System.out.println(a);

System.out.println("Size of Map"+map.size());
}
}
OUTPUT:-

3
JAVA PRACTICAL 2106025

Program 3:-Program for for implementing Wrapper Class:-

public class wrapper_1 {

public static void main (String[] args)


{

//int ---> Integer //2106025


int a=10;

Integer number=new Integer(a);

System.out.println(number);

int j=Integer.valueOf(number);

System.out.println(j);

//double ---> Double

double f=20.21;

Double d= new Double(f);

System.out.println(d);

Double doub=Double.valueOf(d);

System.out.println(doub);

OUTPUT:-

You might also like