-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListToArray.java
More file actions
22 lines (18 loc) · 605 Bytes
/
Copy pathListToArray.java
File metadata and controls
22 lines (18 loc) · 605 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package algorithm.module;
import algorithm.TestCase;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
public class ListToArray implements TestCase {
@Override
public void test() throws ParseException, IOException {
}
public Integer[] solution(int n, int[] numlist) {
ArrayList<Integer> list = new ArrayList<>();
for (int i = 0; i < numlist.length; i++) {
if (numlist[i] % n == 0)
list.add(numlist[i]);
}
return list.stream().toArray(l -> new Integer[l]);
}
}