This might just be a question of personal taste and workflow, but in case it\'s more than that, I feel I should ask anyway.
In Java, what differences are there betwe
The difference is a static factory method is more flexible. It can have all sorts of ways to return an instance. It can do other side stuff. It can have a more descriptive name. It can be invoked by its simple name (e.g. foo(args)
) by static import or inheritance.
The constructor call is more certain - the caller knows exactly what's happening - a new instance of that exact class is created.
There are both advantages and disadvantages of static factory methods.
Advantages
Disadvantages
Source: Effective Java, Second Ed.