Builder Pattern in Effective Java

Make the builder a static class. Then it will work. If it is non-static, it would require an instance of its owning class – and the point is not to have an instance of it, and even to forbid making instances without the builder.

public class NutritionFacts {
    public static class Builder {
    }
}

Reference: Nested classes

Leave a Comment