Why doesn Collection extend Cloneable and Serializable?
Many Collection implementations (including all of the ones provided by the JDK) will have a public clone method, but it would be mistake to require it of all Collections. For example, what does it mean to clone a Collection that’s backed by a terabyte SQL database? Should the method call cause the company to requisition a new disk farm? Similar arguments hold for serializable. If the client doesn’t know the actual type of a Collection, it’s much more flexible and less error prone to have the client decide what type of Collection is desired, create an empty Collection of this type, and use the addAll method to copy the elements of the original collection into the new one. • Why don’t you provide an “apply” method in Collection to apply a given method (“upcall”) to all the elements of the Collection? This is what is referred to as an “Internal Iterator” in the “Design Patterns” book (Gamma et al.). We considered providing it, but decided not to as it seems somewhat redundant to support i