A method to check whether the list is empty or not. - Java java.util

Java examples for java.util:List Operation

Description

A method to check whether the list is empty or not.

Demo Code


//package com.java2s;

import java.util.List;

public class Main {
    public static void main(String[] argv) {
        List listToCheck = java.util.Arrays.asList("asdf", "java2s.com");
        System.out.println(isEmptyList(listToCheck));
    }/*from   w w  w .  jav a 2 s .co  m*/

    /**
     * <p>
     * A method to check whether the <tt>list</tt> is empty or not.
     *</p>
     *
     *
     * @param listToCheck
     *       a <tt>List</tt> which needs to be checked
     *
     * @return
     *       a boolean value (true/false) indicating the status
     */
    public static boolean isEmptyList(List<? extends Object> listToCheck) {
        return (listToCheck.size() <= 0);
    }
}

Related Tutorials