Results for “Java”
Small, practical examples. Search by task or narrow things down below.
Store a value in a named variable
Java: Give a value a descriptive name and print it.
Java✓ Tested
Store a value in a named variable
JavaScript: Give a value a descriptive name and print it.
JavaScript✓ Tested
Sum integer values
Reduce a Java integer stream to its sum.
Java✓ Tested
Sum numeric values
Provide an initial accumulator for JavaScript reduce, including empty arrays.
JavaScript✓ Tested
Take a page from a stream
Java: Use skip and limit with a known stable input order.
Java✓ Tested
Take an immutable list snapshot
Java: List.copyOf protects the snapshot from later changes to the source list.
Java✓ Tested
Transform a resolved promise result
JavaScript: A then handler returns the value passed to the next promise in the chain.
JavaScript✓ Tested
Transform an asynchronous result
Java: Chain thenApply and join a CompletableFuture to retrieve the completed value.
Java✓ Tested
Transform an optional value
Java: Use Optional.map and orElse to transform a possibly absent result.
Java✓ Tested
Transform array values
Use map to create a JavaScript array of squared values.
JavaScript✓ Tested
Transform each regex match with a callback
JavaScript: A replacement callback computes the replacement separately for each match.
JavaScript✓ Tested
Transform each stream value
Java: Use map to turn each input into a corresponding output.
Java✓ Tested