import javaslang.control.Try; public class ExceptionHandlingExample { public static void main(String[] args) { Try<Integer> result = divide(6, 0); result.onSuccess(value -> System.out.println("Result: " + value)) .onFailure(exception -> System.out.println("Error: " + exception.getMessage())); } public static Try<Integer> divide(int a, int b) { return Try.of(() -> a / b); } }


上一篇:
下一篇:
切换中文