forked from PacktPublishing/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
22 lines (17 loc) · 821 Bytes
/
Main.java
File metadata and controls
22 lines (17 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package modern.challenge;
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main(String[] args) {
System.out.println("Convert list of String to list of ints:");
List<String> strList = Arrays.asList("11", "22", "33");
List<Integer> intList = Convertors.list(strList, Integer::parseInt);
System.out.println("strList: " + strList);
System.out.println("intList: " + intList);
System.out.println("\n\nConvert array of String to array of doubles:");
String[] strArr = {"11", "22", "34"};
Double[] doubleArr = Convertors.array(strArr, Double::parseDouble, Double[]::new);
System.out.println("strArr: " + Arrays.toString(strArr));
System.out.println("doubleArr: " + Arrays.toString(doubleArr));
}
}