@Test public void tryremove() throws Exception { List<String> list = new ArrayList<String>(); list.add("9");list.add("888");list.add("846");list.add("654");list.add("844"); System.out.println("list: " + StringUtils.join(list, ",")); if(CollectionUtils.isNotEmpty(list)){ Iterator<String> it = list.iterator(); while(it.hasNext()){ String temp = it.next(); System.out.println(temp); if(temp.startsWith("84")) { it.remove(); } } System.out.println("list: " + StringUtils.join(list, ",")); } } //console: list: 9,888,846,654,844 9 888 846 654 844 list: 9,888,654
文章標籤
全站熱搜
留言列表