Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why doesn Collection extend Cloneable and Serializable?

0
Posted

Why doesn Collection extend Cloneable and Serializable?

0

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

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123