Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.util.Collection;

import java.util.List;

public class Main {
    /**
     *  Returns the first element of the passed list, <code>null</code> if
     *  the list is empty or null.
     */
    public static <T> T first(List<T> list) {
        return isNotEmpty(list) ? list.get(0) : null;
    }

    /**
     *  Returns <code>true</code> if the passed collection is not <code>null</code>
     *  and has size &gt; 0.
     */
    public static boolean isNotEmpty(Collection<?> c) {
        return (c != null) && (c.size() > 0);
    }
}