All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xxl.mathematica.list.Last Maven / Gradle / Ivy

package xxl.mathematica.list;

import java.util.List;

/**
 * 最后一个
 */

public class Last {
    /**
     * 给出list的最后一个元素
     *
     * @param list
     * @param 
     * @return
     */
    public static  T last(List list) {
        return last(list, null);
    }

    /**
     * 如果有任何元素给出最后一个元素,否则给出 def
     *
     * @param list
     * @param def
     * @param 
     * @return
     */
    public static  T last(List list, T def) {
        return io.vavr.collection.List.ofAll(list)
                .lastOption()
                .getOrElse(def);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy