首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > Java > 图为java过滤器和减少

图为java过滤器和减少

资 源 简 介

The map, filter and reduce functions allow working with lists very conveniently. They are known from functional programming. This library brings them to Java. Sample code: ``` List list = Arrays.asList("1", "2", "3", "4", "5", "6", "7"); System.out.println("List of Strings: " + list); // map: String to Integer Collection list2 = new Mapping() { public Integer function(String s) { return Integer.valueOf(s); } }.apply(list); System.out.println("List of Integers: " + list2); // filter: even numbers Collection list3 = new Filter() { public Boolean function(Integer s) { return s % 2 == 0; } }.apply(list2); System.out.println("Filtered even: " + list3); // map with closure: divide every value by 2 final int divisor = 2; Collection list4 = new Mapping() {

文 件 列 表

de
funcy
VIP VIP
0.173688s