Java basic learning notes 7 (4) -- Iterator & amp; Comparable

Source: Internet
Author: User

* ** The Iterator interface Iterator object is called an Iterator for convenient traversal of elements in a container. 1. boolean hasNext () Returns true if the iteration has more elements. if there are still elements in the iterator that can be iterated, Return true (judge whether there are elements on the right of the cursor that can be iterated) 2.E next () Return the next element in the iteration. return the next element of the iteration (return the element on the right of the cursor and move the cursor to the next position) 3. void remove () Removes from the underlying collection the last elementreturn by the iteration. delete the current element pointing to from the iterator (the iterator object's remove method is the only safe way to delete elements during the iteration process) *** all the classes to be sorted by the Comparable interface, java. lang. comparab Le interface. Override the compareTo method. 1. public int compareTo (T obj); Compares this object with the specified object for order. compare this object with the specified object. Return 0 indicating this = obj. Return positive value indicating this> obj. Return negative value indicating this <obj

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.