- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
Latest commit
38 lines (32 loc) · 951 Bytes
/
Copy pathMain.java
File metadata and controls
38 lines (32 loc) · 951 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
importjava.util.*;
publicclassMain {
staticIteratorfunc(ArrayListmylist) {
Iteratorit = mylist.iterator();
while (it.hasNext()) {
Objectelement = it.next();
if (elementinstanceofString && element.equals("###"))
break;
}
returnit;
}
@SuppressWarnings({"unchecked"})
publicstaticvoidmain(String[] args) {
ArrayListmylist = newArrayList();
Scannersc = newScanner(System.in);
intn = sc.nextInt();
intm = sc.nextInt();
for (inti = 0; i < n; i++) {
mylist.add(sc.nextInt());
}
mylist.add("###");
for (inti = 0; i < m; i++) {
mylist.add(sc.next());
}
Iteratorit = func(mylist);
while (it.hasNext()) {
Objectelement = it.next();
System.out.println((String) element);
}
sc.close();
}
}