Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.List;

public class Main {
    /**
     * Returns the first element of a list or null if the list
     * is null or empty.
     * 
     * @param l the list in which to find the first element
     * @return Object the first element of the list
     */
    public static Object getFirstElement(List l) {
        // Return null if list is null or empty
        if (l == null || l.isEmpty())
            return null;

        return l.get(0);
    }
}