Created
December 27, 2019 02:42
-
-
Save upangka/ef723733934ffb614f183a8881de6caa to your computer and use it in GitHub Desktop.
将数字字符串变成list,并将每个值乘以2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.caucoder.nullex; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
/** | |
* 两个map使用 | |
*/ | |
public class StreamMap { | |
public static void main(String[] args) { | |
String str = "1,2,3"; | |
List<Integer> res = Arrays.stream(str.split(",")) | |
.map(Integer::parseInt) | |
.map(StreamMap::Double).collect(Collectors.toList()); | |
System.out.println(res); | |
} | |
public static Integer Double(Integer i){ | |
return i*2; | |
} | |
} | |
/** | |
[2, 4, 6] | |
*/ |
Author
upangka
commented
Dec 27, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment