1. Why does the collection class not implement the cloneable and serializable interfaces?
The semantics and meanings of cloning (cloning) or serialization (serialization) are related to specific implementations. Therefore, the specific implementation of the collection class should determine how to be cloned or serialized.
What is the difference between 2.Iterator and listiterator?
The iterator can be used to traverse the set and list collection, but Listiterator can only traverse the list.
Iterator to a collection can only be forward traversal, listiterator can be either forward or back.
Listiterator implements the iterator interface and includes other functions, such as adding elements, replacing elements, getting the index of the previous and subsequent elements, and so on.
3. What is the difference between fast failure (fail-fast) and security failure (fail-safe)?
Iterator's security failure is based on a copy of the underlying collection, so it is not affected by modifications on the source collection. All of the collection classes below the Java.util package are fast failures, and all classes under the Java.util.concurrent package fail safely. A fast-failing iterator throws an concurrentmodificationexception exception, and a security-failed iterator never throws such an exception.
Java Basic Knowledge Point prerequisites