-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArraylist.java
91 lines (72 loc) · 2.33 KB
/
Arraylist.java
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javapep;
import java.util.ArrayList;
import java.util.Iterator;
/**
*
* @author anil
*/
public class Arraylist {
int nPage;
String author;
int edition;
Arraylist(int n,String author ,int edition)
{
this.author=author;
this.nPage=n;
this.edition=edition;
}
}
class demo{
static int display( ArrayList<Arraylist> al)
{
System.out.println("nPage"+" "+"author"+" " +"edition");
Arraylist b;
Iterator it =al.iterator();
while(it.hasNext())
{
b=(Arraylist)it.next();
System.out.println(b.nPage+" "+b.author+" "+b.edition);
//System.out.println(al);
}
return 0;
}
public static void main(String args[])
{
// ArrayList<String> al= new ArrayList<>();
// al.add("Anil");
// al.add("Vivek");
// al.add("Pankaj");
// al.add("Arvind");
// System.out.println(al);
// Iterator it =al.iterator();
// while(it.hasNext())
// System.out.print(it.next());
// if(al.contains("anil"))
// {
// System.out.println("yes");
// }
// else
// {
// System.out.println("NO");
// }
// for(String a:al)
// System.out.print(a);
// for(int i=0;i<al.size();i++)
// {
// System.out.print(al.get(i));
// }
Arraylist a=new Arraylist(50,"anil",1997);
Arraylist b=new Arraylist(51,"pankaj",1998);
Arraylist c=new Arraylist(52,"deepak",1999);
ArrayList<Arraylist> al= new ArrayList<Arraylist>(); //Generic type arraylist
al.add(a);
al.add(b);
al.add(c);
display(al);
}
}