集册 Java实例教程 测试实体数组是否为空。

测试实体数组是否为空。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

498
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
测试实体数组是否为空。


//package com.nowjava;
//N o w J a v a . c o m

public class Main {

    public static void main(String[] argv) {

        Object[] entities = new String[] { "1", "abc", "level", null,

                "nowjava.com", "asdf 123" };

        System.out.println(isNotEmpty(entities));

    }


    /** Test if entities array is not empty.

     *

     * @param entities to test if is not empty.

     * @return true if entities is not null and its length is more than zero.

     */

    public static boolean isNotEmpty(Object[] entities) {

        return !isEmpty(entities);

    }


    /** Test if entities array is empty.

     *

     * @param entities to test if it is empty.

     * @return true if entities array is null or entities array length is zero.

     */

    public 
展开阅读全文