Why Collection Interface Doesn’t Extend Cloneable and Serializable Interfaces in Java ?

Collection interface just specifies groups of objects known as elements. Each concrete implementation of a Collection can choose its own way of how to maintain and order its elements.

Some collections may allow duplicate keys, while other collections may not.

A lot of collection implementations have clone method. But many do not. It is not worthwhile to include it in all, since Collection is an abstract representation. What matters is the concrete implementation.

Cloning and serialization come into picture while doing concrete implementation. Therefore, the concrete implementations of collections should decide how they can be cloned or serialized.



You May Interest

What are the Rules of Method Overloading and Method Overriding in ...

What are the Differences Between Comparable and Comparator in Jav ...

What is the Reason to Organize Classes and Interfaces in a Packag ...

What are the Differences Between a Checked and Unchecked Exceptio ...

When is UnsupportedOperationException Thrown in Java ?