I was told that this approach:
public class Example{
private String field
Optional<String> getField(){
return Optional.of(field);
}
}
is better than this:
public class Example{
Optional<String> field;
}
My question is why?
I was told that this approach:
public class Example{
private String field
Optional<String> getField(){
return Optional.of(field);
}
}
is better than this:
public class Example{
Optional<String> field;
}
My question is why?