Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;

import java.util.List;

public class Main {

    public static <T> T getLastElement(List<T> liste) {
        if (isEmpty(liste)) {
            return null;
        } else {
            return liste.get(liste.size() - 1);
        }
    }

    public static <T> boolean isEmpty(Collection<T> col) {
        return (col == null) || col.isEmpty();
    }

    public static <T> int size(Collection<T> col) {
        if (col == null) {
            return 0;
        } else {
            return col.size();
        }
    }
}