java,list转数组
- 摘要:List<String>list=newArrayList<String>();if(id!=null&&!"".equals(id)){sb.append("andtw.id=?");list.add(id);}if(memo!=null&&!"".equals(memo)){sb.append("andtw.memolike?");list.add("%"+memo+"%");}sb.append("orderbytw.iddesc"
- 标签:list 数组 Java
List<String> list = new ArrayList<String>();
if(id != null && !"".equals(id)){
sb.append( "and tw.id = ? ");
list.add(id);
}
if(memo!=null && !"".equals(memo)){
sb.append( "and tw.memo like ? ");
list.add("%"+memo+ "%");
}
sb.append( "order by tw.id desc");
String[] params = null;
if(list!= null && !list.isEmpty()){
params= list.toArray(new String[ list.size()]);
}