Created
April 25, 2020 10:08
-
-
Save arindam89/a45b6afb00da1a23692887c3879ab2c1 to your computer and use it in GitHub Desktop.
Try Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// = Success(result) or Failure(exception) | |
Try<Integer> divide(Integer dividend, Integer divisor) { | |
return Try.of(() -> dividend / divisor); | |
} | |
@Test | |
public void createTry() { | |
System.out.println(divide(10,2)); | |
System.out.println(divide(10,0)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment