Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;

public class Main {
    /**
     * Returns the last element of an array list.
     * Returns null if list is empty or null
     * 
     * @param list the ArrayList to search through
     * @return List the resulting element
     */

    public static Object getLastElementOfArrayList(ArrayList list) {
        if (list != null || list.size() >= 0) {
            return list.get(list.size() - 1);
        }
        return null;
    }
}