forked from Krushna-Prasad-Sahoo/JavaCode-Hacktoberfest2021
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimalsArrayList.java
More file actions
Latest commit
29 lines (20 loc) · 614 Bytes
/
Copy pathAnimalsArrayList.java
File metadata and controls
29 lines (20 loc) · 614 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
packagepracticeDemo1;
importjava.util.ArrayList;
publicclassAnimalsArrayList {
publicstaticvoidmain(String[] args) {
ArrayList<String> animals = newArrayList<String>();
animals.add("Lion");
animals.add("tiger");
animals.add("jaguar");
animals.add("Leopard");
animals.add("elephant");
System.out.println("All the animals are ... ");
for (inti=0; i<animals.size(); i++) {
System.out.println(animals.get(i));
}
System.out.println("--------------------------------");
for (Stringanm : animals) {
System.out.println(anm);
}
}
}