Created
January 28, 2018 11:29
-
-
Save abdurahmanadilovic/2b97a1391e32f746bd60f45d8a95cfa5 to your computer and use it in GitHub Desktop.
Java filter functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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