Skip to content

Instantly share code, notes, and snippets.

@brilianfird
Created September 19, 2020 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brilianfird/4a88c8d34aa998fb4c8e80306cff7dde to your computer and use it in GitHub Desktop.
Save brilianfird/4a88c8d34aa998fb4c8e80306cff7dde to your computer and use it in GitHub Desktop.
List<String> stringList = Arrays.asList("Hello", "World", "How", "Are", "You", "Today");
// imperative declaration
List<String> filteredList = new ArrayList<>();
for (String string: stringList) {
if (string.equals("Hello") || string.equals("Are")) {
filteredList.add(string);
}
}
List<String> mappedList = new ArrayList<>();
for (String string: filteredList) {
mappedList.add(string + " String");
}
for (String string: mappedList) {
System.out.println(string);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment