hello
This commit is contained in:
BIN
TestJavaCollection2.class
Normal file
BIN
TestJavaCollection2.class
Normal file
Binary file not shown.
14
TestJavaCollection2.java
Normal file
14
TestJavaCollection2.java
Normal file
@@ -0,0 +1,14 @@
|
||||
import java.util.*;
|
||||
public class TestJavaCollection2{
|
||||
public static void main(String args[]){
|
||||
LinkedList<String> al=new
|
||||
LinkedList<String>();
|
||||
al.add("Ravi");
|
||||
al.add("Vijay");
|
||||
al.add("Ajay");
|
||||
Iterator<String>itr=al.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
TestJavaCollection3.class
Normal file
BIN
TestJavaCollection3.class
Normal file
Binary file not shown.
15
TestJavaCollection3.java
Normal file
15
TestJavaCollection3.java
Normal file
@@ -0,0 +1,15 @@
|
||||
//write a java code to demonstrate vector
|
||||
import java.util.*;
|
||||
public class TestJavaCollection3{
|
||||
public static void main(String args[]){
|
||||
Vector<String> v=new Vector<String>();
|
||||
v.add("Ayush");
|
||||
v.add("Amit");
|
||||
v.add("Ashish");
|
||||
v.add("Garima");
|
||||
Iterator<String>itr=v.iterator();
|
||||
while(itr.hasNext()){
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
16
VectorDemo.java
Normal file
16
VectorDemo.java
Normal file
@@ -0,0 +1,16 @@
|
||||
import java.util.Vector;
|
||||
public class VectorDemo{
|
||||
public static void main(String[] args){
|
||||
//creating a Vector
|
||||
Vector<String> vector = new Vector <>();
|
||||
//Adding elements to the Vector
|
||||
vector.add("Item X");
|
||||
vector.add("Item Y");
|
||||
vector.add("Item Z");
|
||||
System.out.println("Element at index 0:" + vector.get(0));
|
||||
System.out.println("Element at index 0:" + vector.get(1));
|
||||
System.out.println("Element at index 0:" + vector.get(2));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user