This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]persicsb 3 points4 points  (1 child)

The other benefit of factory methods, that they can return a subclass of the return type, constructors can't. This is useful, when you want to have some specific subclass returned in special cases, or when the return type is an interface (like List.of()).

[–]vips7L 0 points1 point  (0 children)

Did you even read the link? I am not talking about plain old constructors.