I'm wondering if there is an exit in the use of Optional.ofNullable()
for(String name: names){
if(name != null)
person = "Mr./Mrs."+name;
else
continue;
greeting(person);
}
My code is like above. I want to check the argument before calling the function. I have similar codes in my class and to reduce complexity I want to use Optional.Nullable()
.
Is there a way to apply Optional.Nullable()
in here? Or is there another way to help me to reduce complexity of multiple if checks to check null variables? Thanks in advance.