public static void main(String[] args) {
TreeMap<String,String> map = new TreeMap<>();
map.put("bizContent","bizContent.toString()");
map.put("appId",Configs.APPID.toString());
map.put("timestamp","timestamp.toString()");
map.put("serviceName","serviceName");
map.put("key",Configs.key);
final String s = new Gson().toJson(map);
Map<String,String> map2 = new HashMap<>();
map2.put("bizContent","bizContent.toString()");
map2.put("appId",Configs.APPID.toString());
map2.put("timestamp","timestamp.toString()");
map2.put("serviceName","serviceName");
map2.put("key",Configs.key);
map2.entrySet().stream()
.map(e -> e.getKey() + ": " + e.getValue())
.forEach(System.out::println);
String collect = map.entrySet().stream()
.map(e -> e.getKey() + "=" + e.getValue())
.collect(Collectors.joining("&"));
System.out.println(collect);
String collect2 = map2.entrySet().stream()
.map(e -> e.getKey() + "=" + e.getValue())
.collect(Collectors.joining("&"));
System.out.println(collect2);
Stream.of("i am ben".split(" ")).forEach((i)-> System.out.print(i+" " ));
//System.out.println("S="+s);
Random rand = new Random(47);
show(rand.ints(2).boxed());
show(rand.ints(10).boxed());
new RequestModel().numbers().limit(10)
.map(k-> k+"=" )
.forEach((i)-> System.out.print(i+" " ));
System.out.println();
rands().limit(SZ)
.forEach(n -> System.out.format("%d ", n));
System.out.println();
rands().limit(SZ)
.parallel()
.forEach(n -> System.out.format("%d ", n));
System.out.println();
rands().limit(SZ)
.parallel()
.forEachOrdered(n -> System.out.format("%d ", n));
}
static final int SZ = 14;
private static int[] rints = new Random(47).ints(0, 1000).limit(100).toArray();
public static IntStream rands() {
return Arrays.stream(rints);
}
int x = 1;
Stream<Integer> numbers() {
return Stream.iterate(0, i -> {
int result = x + i;
x = i;
return result;
});
}
public static <T> void show(Stream<T> stream) {
stream
.limit(3)
.forEach(System.out::println);
System.out.println("++++++++");
}
2020-12-07 JAVA LIST MAP STREAM
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- info.getSysFiles().stream().mapToDouble(SysFile::getUsage...
- java stream处理list根据多个字段判断重复 List去重复 ,我们首先想到的可能是 利用List转S...
- 1.对多个属性去重 2.分组 3.过滤 4.list转map 5.map转list 6.遍历map
- 本套JAVA8教程由于是有英文翻译过来的,如果有翻译不对的地方还请多多包涵。 本节课先简单的介绍下Java8有哪些...