I was reading effective java and one advantage of static factory method written is they can return an object of any subtype of return type. I understood the way we can implement this as mentioned in following link with example. http://ift.tt/2iX4Ca5 But in the book an example of Collections API is given that has static factory methods in java.util.Collections utility class and it is written that "Collections API is much smaller than it would have been had it exported 32 separate public classes".
It is also mentioned that in this manner Api can return objects without making their classes public and this results in very compact API. I want to know how the API size is reduced by implementing this method and not having separate public classes.
Aucun commentaire:
Enregistrer un commentaire