Java: Iterator and listiterator of the set output

Source: Internet
Author: User

Java: Iterator and listiterator of the set output

Listiterator is the sub-interface of the iterator, and the greatest feature of iterator is the ability to iterate forward or backward. If you want to output two-way, you can only use the Listiterator interface, this interface has a requirement that only the contents of the list interface can be output. So use the public listiterator<e> extends Iterator<e>:

Add (E): Add data

Boolean hasnext (); Inherit iterator, whether the next element exists,

Next (); Inherit iterator, get the next element content

Previous (); Inherit iterator, get the previous element content

Remove (); Delete the next or previous element

Set (e e); Replace the contents of the next or previous element with the specified element;

If you want two-way output, it is important to first ensure that the output is performed by the front and back.

When using the Listiterator interface, there is also the biggest feature that can increase the modification data.

Java: Iterator and listiterator of the set output

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.