Just trying out a simple example to understand exception handling when it comes to streaming with foreachordered. Please write down suggestions on how we can continue performing actions on next element of list(20) when the current element threw exception (1).
try {
List<Integer> list = Arrays.asList(10, 1, 20, 15, 2);
list.stream().forEachOrdered(num->{
if(num>2) {
System.out.println(num);
}else {
int result=num/0;
System.out.println(result);
}
});
}catch(Exception e) {
System.out.println("Exception: "+e);
}