get Array Dimension from its to String representation - Android java.lang

Android examples for java.lang:array

Description

get Array Dimension from its to String representation

Demo Code

import android.util.Pair;
import java.util.Arrays;

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;/*ww  w  . j  av  a  2s . c  o  m*/
            } else {
                break;
            }
        }
        return dim;
    }

}

Related Tutorials