语法格式:(parameters) -> expression 或 (parameters) ->{ statements; }
创建一个 String 类型的数组
static String[] atp = {"11", "22","33", "44", "55", "66"};
用 Arrays 的 asList 方法将其转换为 List 集合
- static List<String> players = Arrays.asList( atp );
- // 以前使用超级 for 循环遍历集合
- public static void main(String[] args) {
- for (String player : players) {
- System.out.print( player + ";" );
- }
- // 使用 lambda 表达式以及函数操作 (functional operation)
- //players.forEach((player) -> System.out.print(player + ";"));
来源: http://www.bubuko.com/infodetail-2726998.html