Skip to content

Instantly share code, notes, and snippets.

@haydarai
Created February 7, 2017 12:55
Show Gist options
  • Save haydarai/813ac39123b9e50241f801b8c5978240 to your computer and use it in GitHub Desktop.
Save haydarai/813ac39123b9e50241f801b8c5978240 to your computer and use it in GitHub Desktop.
List<Post> posts = ...; // Fill the list with data
List<Post> filteredPost = new ArrayList<>();
// Iterate through the collection
for (Post post : posts) {
if (post.getAuthor().equals("Haydar") // The filter condition
filteredPost.add(post); // Adding the filtered item to the filtered collection
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment