I am trying to apply a function to a list of value, if in this function the value match, It returns an MyExceptions(a custom kind of Exceptions). I a use a single value like this:
myFunctions.checkValue(myValue);
I can throws MyExceptions directly in my function declaration, but if I have a list of value, I can't use the throws but I have to use try/catch. Like this:
public void firstCheckValue(String value1,List<String> listValue) throws MyException{
        myFunctions.checkValue(value1);
        listValue.stream().forEach(p->{
        try {
            listValue.checkValue(p);
        } catch (MyException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    });
}
Why I can't use :
listValue.stream().forEach(p->myFunctions.checkValue(p));
And directly throws MyExceptions?
 
     
     
    