-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment105_.java
More file actions
34 lines (24 loc) · 891 Bytes
/
Assignment105_.java
File metadata and controls
34 lines (24 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package abhilash_Asignments;
//"WAP using Iterator (process of iteration through iterable )"
import java.util.ArrayList;
import java.util.Iterator;
public class Assignment105_
{
public static void main(String[] args) //main method
{
ArrayList L1 = new ArrayList (); //ArrayList "it does not have length
L1.add("This");
L1.add("Automation"); //Adding the "Different types Elements to ArrayList"
L1.add("testing");
L1.add("by");
L1.add("MKT");
L1.add(42);
System.out.println(L1); //Printing the ArrayList Statement
Iterator iterator = L1.iterator(); //using iterator function the list is done iteration
while (iterator.hasNext()) //While loop for iteration with function hasnext is used for print next element
{
Object List = iterator.next();
System.out.println(List);
}
}
}