package com.panzhihua.common.utlis; /** * 应用模块名称 *

* 代码描述 *

* Copyright: Copyright (C) 2022 XXX, Inc. All rights reserved. *

* Company: 成都呐喊信息技术有限公司 *

* * @author manailin * @since 2022/2/17 14:33 */ import java.util.Objects; import java.util.function.BiConsumer; /** * * @author yangzhilong * @date 7/15/2019 */ public class ForEachUtils { /** * * @param * @param startIndex * 开始遍历的索引 * @param elements * 集合 * @param action */ public static void forEach(int startIndex, Iterable elements, BiConsumer action) { Objects.requireNonNull(elements); Objects.requireNonNull(action); if (startIndex < 0) { startIndex = 0; } int index = 0; for (T element : elements) { index++; if (index <= startIndex) { continue; } action.accept(index - 1, element); } } }