-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
37 lines (28 loc) · 842 Bytes
/
Main.java
File metadata and controls
37 lines (28 loc) · 842 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
package Q2;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<String> ss = new ArrayList<>();
ss.add("10");
ss.add("20");
ss.add("40");
ss.add("50");
ss.add("60");
ss.add("70");
ss.add("80");
System.out.println("ArrayList: " + ss);
// Using forEach loop
System.out.println("Iterating over ArrayList using for-each loop:");
for(String language : ss) {
System.out.print(ss);
System.out.print("----");
}
//Using for loop simple
System.out.println("Iterating over ArrayList using for loop: ");
for(int i = 0; i < ss.size(); i++) {
System.out.print(ss.get(i));
System.out.print("----");
}
}
}