List常用操作

是否包含字符串

String userid
List<String> userIdList
userIdList.contains(userid) 

userIdList中包含 "user1"  "user2" "user3"

userIdList.contains("user1") 显示 true

userIdList.contains("user4") 显示 false

反向遍历

List<WpFolder> list = this.getFolderPath(folderid);
ListIterator<WpFolder> it=list.listIterator(list.size());
StringBuffer sb = new StringBuffer();
while(it.hasPrevious()){  
WpFolder folder = it.previous();
  sb.append("<a href='#' onclick='refreshContent(\""+folder.getFolderid()+"\")'>"+folder.getFoldername()+"</a><span>></span>");
  sb.append("\n");
}

List去除重复字符串对象

List<String> deptIdList = new ArrayList();
HashSet h = new HashSet(deptIdList);
deptIdList.clear();
deptIdList.addAll(h);





你可能感兴趣的:(List常用操作)