Java Basic Knowledge Point prerequisites

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.