Added till 18th
BIN
LinkedHash17a.class
Normal file
16
LinkedHash17a.java
Normal file
@@ -0,0 +1,16 @@
|
||||
// 17a) Write a java code to demonstrate LinkedHashSet
|
||||
|
||||
import java.util.*;
|
||||
public class LinkedHash17a{
|
||||
public static void main(String args[]){
|
||||
LinkedHashSet<String> pc = new LinkedHashSet<String>();
|
||||
pc.add("RAM stick");
|
||||
pc.add("GPU");
|
||||
pc.add("RAM stick");
|
||||
pc.add("Processor");
|
||||
Iterator<String> itr = pc.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
LinkedHash17b.class
Normal file
15
LinkedHash17b.java
Normal file
@@ -0,0 +1,15 @@
|
||||
import java.util.*;
|
||||
public class LinkedHash17b{
|
||||
public static void main(String args[]){
|
||||
LinkedHashSet<String> pc = new LinkedHashSet<String>();
|
||||
pc.add("RAM stick");
|
||||
pc.add("GPU");
|
||||
pc.add("");
|
||||
pc.add("RAM stick");
|
||||
pc.add("Processor");
|
||||
Iterator<String> itr = pc.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
LinkedHash17c.class
Normal file
15
LinkedHash17c.java
Normal file
@@ -0,0 +1,15 @@
|
||||
import java.util.*;
|
||||
public class LinkedHash17c{
|
||||
public static void main(String args[]){
|
||||
LinkedHashSet<String> pc = new LinkedHashSet<String>();
|
||||
pc.add("RAM stick");
|
||||
pc.add("GPU");
|
||||
pc.add(null);
|
||||
pc.add("RAM stick");
|
||||
pc.add("Processor");
|
||||
Iterator<String> itr = pc.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
LinkedList13b.class
Normal file
16
LinkedList13b.java
Normal file
@@ -0,0 +1,16 @@
|
||||
import java.util.*;
|
||||
|
||||
public class LinkedList13b {
|
||||
public static void main(String args[]){
|
||||
LinkedList<String> name = new LinkedList<String>();
|
||||
name.add("Misa");
|
||||
name.add("Aditya");
|
||||
name.add("Misa");
|
||||
name.add("Aisha");
|
||||
Iterator<String> itr = name.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
26
LinkedListDemo.java
Normal file
@@ -0,0 +1,26 @@
|
||||
// 13. write a java program to demonstrate Linked List
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class LinkedListDemo {
|
||||
public static void main(String[] args) {
|
||||
|
||||
LinkedList<String> linkedList = new LinkedList<>();
|
||||
|
||||
linkedList.add("Element A");
|
||||
linkedList.add("Element B");
|
||||
linkedList.add("Element C");
|
||||
|
||||
System.out.println("Element at index 0: " + linkedList.get(0));
|
||||
System.out.println("Element at index 1: " + linkedList.get(1));
|
||||
System.out.println("Element at index 2: " + linkedList.get(2));
|
||||
|
||||
System.out.println("LinkedList Elements:");
|
||||
for (String element : linkedList) {
|
||||
System.out.println(element);
|
||||
}
|
||||
|
||||
linkedList.remove("Element B");
|
||||
System.out.println("Size of linked list after removal: " + linkedList.size());
|
||||
}
|
||||
}
|
||||
BIN
Stack15.class
Normal file
25
Stack15.java
Normal file
@@ -0,0 +1,25 @@
|
||||
// write a java code to demonstrate Stack
|
||||
import java.util.*;
|
||||
public class Stack15 {
|
||||
public static void main(String ar[]){
|
||||
Stack<String> elec = new Stack<String>();
|
||||
elec.push("fan");
|
||||
elec.push("air conditioner");
|
||||
elec.push("computer");
|
||||
elec.push("iron");
|
||||
elec.push("lights");
|
||||
|
||||
Iterator<String> itr = elec.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
String topOfStack = elec.peek();
|
||||
System.out.println("The top electrical item is : " + topOfStack);
|
||||
elec.pop();
|
||||
System.out.println("After Pop : ");
|
||||
Iterator<String> newItr = elec.iterator();
|
||||
while(newItr.hasNext()){
|
||||
System.out.println(newItr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
TreeSet18a.class
Normal file
15
TreeSet18a.java
Normal file
@@ -0,0 +1,15 @@
|
||||
// write a java code to demonstrate treeset
|
||||
import java.util.*;
|
||||
public class TreeSet18a {
|
||||
public static void main(String args[]){
|
||||
TreeSet<String> home = new TreeSet<String>();
|
||||
home.add("Hall Room");
|
||||
home.add("Bed Room");
|
||||
home.add("Bed Room");
|
||||
home.add("Kitchen");
|
||||
Iterator<String> itr = home.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
TreeSet18b.class
Normal file
16
TreeSet18b.java
Normal file
@@ -0,0 +1,16 @@
|
||||
// write a java code to demonstrate treeset
|
||||
import java.util.*;
|
||||
public class TreeSet18b {
|
||||
public static void main(String args[]){
|
||||
TreeSet<String> home = new TreeSet<String>();
|
||||
home.add("Hall Room");
|
||||
home.add("Bed Room");
|
||||
home.add(null);
|
||||
home.add("Bed Room");
|
||||
home.add("Kitchen");
|
||||
Iterator<String> itr = home.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Vector14a.class
Normal file
16
Vector14a.java
Normal file
@@ -0,0 +1,16 @@
|
||||
// write a java code to demonstrate vector (a)
|
||||
|
||||
import java.util.*;
|
||||
public class Vector14a {
|
||||
public static void main(String ar[]){
|
||||
Vector<String> names = new Vector<String>();
|
||||
names.add("Misa");
|
||||
names.add("Aditya");
|
||||
names.add("Ashish");
|
||||
names.add("Garima");
|
||||
Iterator<String> itr = names.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Vector14b.class
Normal file
22
Vector14b.java
Normal file
@@ -0,0 +1,22 @@
|
||||
import java.util.Vector;
|
||||
public class Vector14b {
|
||||
public static void main(String args[]){
|
||||
Vector<String> itemList = new Vector<String>();
|
||||
itemList.add("Item A");
|
||||
itemList.add("Item B");
|
||||
itemList.add("Item C");
|
||||
|
||||
System.out.println("Item at index 0: " + itemList.get(0));
|
||||
System.out.println("Item at index 1: " + itemList.get(1));
|
||||
System.out.println("Item at index 2: " + itemList.get(2));
|
||||
|
||||
System.out.println("Items in Vector list: ");
|
||||
for(String item: itemList) {
|
||||
System.out.println(item);
|
||||
}
|
||||
|
||||
itemList.remove("Item B");
|
||||
System.out.println("Size of Vector after removal: " + itemList.size());
|
||||
}
|
||||
}
|
||||
|
||||
BIN
hashSet16.class
Normal file
18
hashSet16.java
Normal file
@@ -0,0 +1,18 @@
|
||||
// Write a java code to demonstrate hashSet
|
||||
|
||||
import java.util.*;
|
||||
public class hashSet16 {
|
||||
public static void main(String args[]){
|
||||
HashSet<String> setName = new HashSet<String>();
|
||||
setName.add("Misa");
|
||||
setName.add("Aditya");
|
||||
setName.add("Misa");
|
||||
setName.add("Ravi");
|
||||
|
||||
Iterator<String> itr = setName.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
src/13b.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
src/14a.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
src/14b.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
src/15.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
src/16.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
src/17a.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
src/17b.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
src/17c.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
src/18a.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
src/18b.png
Normal file
|
After Width: | Height: | Size: 24 KiB |