java - How to see if an object is an array without using reflection? -
how can see in java if object array without using reflection? , how can iterate through items without using reflection?
i use google gwt not allowed use reflection :(
i love implement following methods without using refelection:
private boolean isarray(final object obj) { //??.. } private string tostring(final object arrayobject) { //??.. }
btw: neither want use javascript such can use in non-gwt environments.
you can use class.isarray()
public static boolean isarray(object obj) { return obj!=null && obj.getclass().isarray(); }
this works both object , primitive type arrays.
for tostring take @ arrays.tostring
. you'll have check array type , call appropriate tostring
method.
Comments
Post a Comment