集册 Java实例教程 是空数组

是空数组

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

481
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
是空数组


//package com.nowjava;

/** from 
时 代 J a v a**/

public class Main {

    public static void main(String[] argv) throws Exception {

        Object result = "nowjava.com";

        System.out.println(isEmptyArray(result));

    }


    public static boolean isEmptyArray(Object result) {

        if (result.getClass().isArray()) {

            if (result instanceof byte[]) {

                return (((byte[]) result).length == 0);

            } else if (result instanceof short[]) {//from 时代Java - nowjava.com

                return (((short[]) result).length == 0);

            } else if (result instanceof int[]) {

                return (((int[]) result).length == 0);

            } else if (result instanceof long[]) {

                return (((long[]) result).length == 0);

            } else if (result instanceof float[]) {

                return (((float[]) result).length == 0);

            } else if (result instanceof double[]) {

                return (((double[]) result).length == 0);

            } else if (result instanceof char[]) {

                return (((char[]) result).length == 0);

            } else if (result 
展开阅读全文