Skip to content

Instantly share code, notes, and snippets.

@abdurahmanadilovic
Created January 28, 2018 11:29
Show Gist options
  • Save abdurahmanadilovic/2b97a1391e32f746bd60f45d8a95cfa5 to your computer and use it in GitHub Desktop.
Save abdurahmanadilovic/2b97a1391e32f746bd60f45d8a95cfa5 to your computer and use it in GitHub Desktop.
Java filter functions
@Test
public void testListFiltering() throws Exception{
List<String> listOfLinks = new ArrayList<>();
listOfLinks.add("www.codingstoic.com");
listOfLinks.add("www.codingblast.com");
listOfLinks.add("www.kotlinlang.org");
listOfLinks.add("www.android.com");
// filter all domains with .com domain
List<String> filteredList = new ArrayList<>();
for (String link: listOfLinks){
if(link.contains(".com")){
filteredList.add(link);
}
}
assertEquals(3, filteredList.size());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment