forked from anandpatel88/JavaPrograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayListObject.java
More file actions
43 lines (37 loc) · 1009 Bytes
/
Copy pathArrayListObject.java
File metadata and controls
43 lines (37 loc) · 1009 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
35
36
37
38
39
40
41
42
43
package JavaPgm;
import java.util.ArrayList;
import java.util.Iterator;
public class ArrayListObject
{
String name;
int empN;
int age;
boolean status;
public ArrayListObject(String name,int empN,int age,boolean status)
{
this.name=name;
this.empN=empN;
this.age=age;
this.status=status;
}
public static void main(String[] args)
{
ArrayListObject alo1=new ArrayListObject("Anand", 12, 23, true);
ArrayListObject alo2=new ArrayListObject("Amit", 13, 24, true);
ArrayListObject alo3=new ArrayListObject("Sara", 14, 28, false);
ArrayList<ArrayListObject> arr=new ArrayList<ArrayListObject>();
arr.add(alo1);
arr.add(alo2);
arr.add(alo3);
System.out.println(arr.get(0).name);
Iterator<ArrayListObject> it=arr.iterator();
while(it.hasNext())
{
ArrayListObject alo=it.next();
System.out.println(alo.name);
System.out.println(alo.empN);
System.out.println(alo.age);
System.out.println(alo.status);
}
}
}