[java]代码库
package s0218lambda表达式;
//目前只会用于遍历数组
import java.util.Arrays;
import java.util.List;
public class Test {
public static void main(String[] args) {
String[] atp = {"Rafael Nadal", "Novak Djokovic",
"Stanislas Wawrinka",
"David Ferrer","Roger Federer",
"Andy Murray","Tomas Berdych",
"Juan Martin Del Potro"};
List<String> players = Arrays.asList(atp);
// // 以前的循环方式
// for (String player : players)
// {System.out.print(player + "; ");}
// 使用 lambda 表达式以及函数操作(functional operation)
players.forEach((player) -> System.out.println(player + "; "));
// // 在 Java 8 中使用双冒号操作符(double colon operator)
// players.forEach(System.out::println);
}
}
初级程序员
by: 云代码会员 发表于:2016-06-09 23:08:25 顶(0) | 踩(0) 回复
我要积分啊!
回复评论