DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Lalit has posted 1 posts at DZone. View Full User Profile

Collection Filter

10.01.2009
| 2694 views |
  • submit to reddit
        // description of your code here

List<String> stringList=new ArrayList();
stringList.add("11");
stringList.add("21");
stringList.add("31");
stringList.add("101");
stringList.add("111");

Collection filteredCollection=CollectionUtils.select(stringList,new Predicate(){
			public boolean evaluate(final Object dto) {
				return (dto.startsWith("1"));
			}			
		});