java 8 爲 Iterable 增加了forEach(Consumer<? super T> action)方法
需要傳入對的參數是個函數式接口
collction 繼承自Iterable
List<String> collection = new ArrayList<>();
collection.forEach(Object ->{
});
collection 的removeIf(Predicate<? super E> filter) 方法也是需要傳入函數式接口的方法,刪除符合傳入條件的元素
例:collection.removeIf(obj -> obj.length()>10); 刪除集合中長度大於10的元素