get First element from ArrayList - Android java.util

Android examples for java.util:ArrayList

Description

get First element from ArrayList

Demo Code


//package com.java2s;

import java.util.ArrayList;
import java.util.Collection;

public class Main {
    public final static <T> T getFirst(ArrayList<T> list) {
        if (list != null && list.size() > 0) {
            return list.get(0);
        }/*  w  w w.j a va  2s  .c o  m*/
        return null;
    }

    public final static int size(Collection c) {
        return c == null ? 0 : c.size();
    }
}

Related Tutorials