Prototype: implement <T> Optional<T> first(List<T> values). Return empty only for an empty list, otherwise the first element. Null elements are outside the domain; do not mutate input.

Final: implement <T,R> List<R> map(List<? extends T> values, Function<? super T,? extends R> transform). Apply transform exactly once per element in encounter order, return a fresh list, preserve input, and propagate a transform's exception unchanged. Results may be null. Empty input invokes no transform. Keep the generic signatures: tests compile a Number consumer against Integer inputs.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.

Java runs on this device with CheerpJ 4.3.