1. 程式人生 > >判斷Object物件型別的關鍵字

判斷Object物件型別的關鍵字


關鍵字:instanceof




   Object param = params.get(i);
   if (param instanceof Integer) {
    int value = ((Integer) param).intValue();
    prepStatement.setInt(i + 1, value);
   } else if (param instanceof String) {
    String s = (String) param;
    prepStatement.setString(i + 1, s);}