集册 Java实例教程 从数组实体获取大小。

从数组实体获取大小。

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

474
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
从数组实体获取大小。


//package com.nowjava;/** 时代Java公众号 - 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(getSizeFromArray(entities));

    }


    /** Get size from an array entities.

     *

     * @param entities to get its size.

     * @return entities size.

     */

    public static Integer getSizeFromArray(Object[] entities) {

        return isNotEmpty(entities) ? entities.length : 0;

    }


    /** 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);
        /**
         from
        * n o w j a   v  a . c o m - 时  代  Java 
        **/

    }


    
展开阅读全文