Closed Auraliano closed 9 years ago
Then you probably should consider the builder pattern. https://github.com/cxxr/better-java#the-builder-pattern
Builder pattern can resolve this question,But If it only has one attribute, why do you need to create a class?
In Java, everything is an object.
If a class includes only one string attribute ,Why not use string directly?
Maybe we can use 'Optional' in java8!
It was an example.
public class DataHolder { public final String data;
}
If it has many properties , create many construct method ? it similar to use get()/set() way