集册 Java实例教程 对象是数组吗

对象是数组吗

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

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


//package com.nowjava;
/** 来自 时 代 J a v a 公 众 号 - N o w J a v  a . c o m**/

public class Main {

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

        Object o = "nowjava.com";

        System.out.println(isArray(o));

    }


    public static boolean isArray(Object o) {

        if (o instanceof char[]) {// char

            return true;

        } else if (o instanceof boolean[]) {// boolean

            return true;

        } else if (o instanceof byte[]) {// byte

            return true;

        } else if (o instanceof short[]) {// short/** 来自 时 代 J a v a 公 众 号 - nowjava.com**/

            return true;

        } else if (o instanceof int[]) {// int

            return true;

        } else if (o instanceof long[]) {// long

            return true;

        } else if (o instanceof float[]) {// float

            return true;
展开阅读全文