已知
map.get("id")為數字,如:123
問題
id.equals(123)
結果為false
而使用
int id = (Integer)map.get("id");
則會報異常(類型轉換異常)
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Integer
解決
Object id1 = map.get("id");
int id = Integer.parseInt(String.valueOf(id1));
結果則為true