Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Nested-function/Java/nested-function.java
Normal file
17
Task/Nested-function/Java/nested-function.java
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class NestedFunctionsDemo {
|
||||
|
||||
static String makeList(String separator) {
|
||||
AtomicInteger counter = new AtomicInteger(1);
|
||||
|
||||
Function<String, String> makeItem = item -> counter.getAndIncrement() + separator + item + "\n";
|
||||
|
||||
return makeItem.apply("first") + makeItem.apply("second") + makeItem.apply("third");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(makeList(". "));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue