java - How to find out the type of an array? -
java - How to find out the type of an array? -
suppose have method public static void amethod(t[] items)
. how find out if items of type string or int or double? used instanceof
im not sure of.
public static void amethod(t[] items) { for(int = 0; < items.length; i++) { if(items[i] instanceof string) { } } }
generally class class has methods may help, example:
object ob = new bigdecimal("30"); system.out.println(ob.getclass().getcanonicalname());
result: java.math.bigdecimal
java
Comments
Post a Comment