Skip to content

Instantly share code, notes, and snippets.

@arindam89
Created April 25, 2020 10:08
Show Gist options
  • Save arindam89/a45b6afb00da1a23692887c3879ab2c1 to your computer and use it in GitHub Desktop.
Save arindam89/a45b6afb00da1a23692887c3879ab2c1 to your computer and use it in GitHub Desktop.
Try Example
// = 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