常见的情况是,我们从mysql读出了数据,批量灌入到HASHMAP里,于是这个HashMap里,有int类型,有string,有boolean,有long 下面的函数,直接判断出数据的类型,方便我们做转义的操作。之前写过一个instanceof 的专门用法。 public static <T> String getType(T t){ if(t instanceof String){ return "string"; }else if(t instanceof Integer){ return "int"; }else if(t instanceof Boolean){ return "boolean"; }else{ return " do not know"; } } 一般这么用。 Iterator iter = h.entrySet().iterator(); while …
继续阅读 →