使用Lambda表达式遍历集合(forEach方法)

使用Lambda表达式遍历集合(forEach方法) Java8为Iterable接口新增forEach(Consumer action)方法,Iterable接口是Collection接口的父接口,Collection集合也可调用该方法。当程序调用该方法遍历时,会依次将集合元素传给Consumer的accept(T t)方法(Iterable接口中惟一的抽象方法)。java public cla
相关文章
相关标签/搜索