I wrote a Wrapper class for few a strings.
public class StringsWrapper {
private String name;
private String surname;
private String socialSecurity;
public StringsWrapper()
{
name = null;
surname = null;
socialSecurity = null;
}
//getters and setters
...}
There are three scenarios:
- I will set only name and surname, leaving
socialSecurity = null - I will set only surname and socialSecurity,
leaving name = null - I will set only surname,
leaving name = nullandsocialSecurity = null
My question: would be preferable to use null when an attribute it's not needed or should I use maybe instances of Java 8's Optional?