for(String str: list){ if(someCondition(str)){ list2.add(doSomeThing(str)); } else{ list2.add(doSomethingElse(str)); }
}with an equivalent using Java 8's functional programming techniques (lambda expressions, etc.).
Spent a couple of hours searching for online tutorials, but they all seem to take the easy way out when they show how to migrate from "old Java" to "new Java" - the examples they offer include if statement without else, if statement just checking for null, etc. Fortunately, this entry on StackExchange may have what I'm looking for:
Replacing if-else from for loops with streams
No comments:
Post a Comment