instanceof 判断类型

private String generateExecuteSql(Collection list , String sympol) { StringBuffer br = new StringBuffer(); for (Iterator itr = list.iterator(); itr.hasNext(); ) { Object obj = itr.next(); if (obj instanceof Integer) { Integer id = (Integer) obj; br.append(id); if (itr.hasNext()) { br.append(sympol); } } else if (obj instanceof String) { String id = (String) obj; br.append(id); if (itr.hasNext()) { br.append(sympol); } } } return br.toString(); } obj instanceof Integer 判断类型  

你可能感兴趣的:(Java知识)