Difference between revisions of "Optional Assignment"
Jump to navigation
Jump to search
(→Test) |
(→Max) |
||
Line 6: | Line 6: | ||
<nowiki>public static Optional<Integer> maximum(ImmutableList<Integer> xs)</nowiki> | <nowiki>public static Optional<Integer> maximum(ImmutableList<Integer> xs)</nowiki> | ||
+ | |||
+ | Given a list of Integers, return [https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#of-T- Optional.of] the maximum value in that list if it exists, otherwise return [https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#empty-- Optional.empty]. | ||
=Test= | =Test= |
Revision as of 13:00, 22 September 2020
Note this studio is required. It helps us gain experience using java.util.Optional<T>.
Code To Implement
Max
class: | Max.java | |
methods: | max | |
package: | optional.assignment | |
source folder: | src/main/java |
public static Optional<Integer> maximum(ImmutableList<Integer> xs)
Given a list of Integers, return Optional.of the maximum value in that list if it exists, otherwise return Optional.empty.
Test
NOTE: in order to test this studio you must first complete the main (non-app) part of the ImmutableList<E> studio.
class: | MaxTestSuite.java | |
package: | optional.assignment | |
source folder: | src/test/java |