get Array Dimension - Android java.lang

Android examples for java.lang:Array Element

Description

get Array Dimension

Demo Code


//package com.java2s;

public class Main {

    public static int getArrayDimension(Object objects) {
        int dim = 0;
        for (int i = 0; i < objects.toString().length(); ++i) {
            if (objects.toString().charAt(i) == '[') {
                ++dim;/*w  w w . j  a v a  2  s  . c  o  m*/
            } else {
                break;
            }
        }
        return dim;
    }
}

Related Tutorials