Java Iterator iterable Collection abstractcollection Map Relationship

Source: Internet
Author: User

Java.lang

The Interface iterable<t> implements the interface so that the For-each loop can be used.

Java.util

Interface iterator<e> is used to traverse collection, there is a hasnext (), Next (), remove () method.

Java.util

Interface collection<e> The root interface in the entire Collection system, the parent interface is iterable. Iterator can be generated.

Java.util

Interface map<k,v> Map is not collection, it can only generate collection. Iterator is a function of collection and cannot be used directly in map.

Java.util

Public static Interface map.entry<k,v> is a nested class of map<k,v>, and a map.entrymap is an entry in the Map. The map's EntrySet () method returns SET<MAP.ENTRY<K,V>>, which can be used to traverse the map.

// recommended, especially when the capacity is large 2  for (map.entry<string, string> entry:map.entrySet ()) {3 System.out.println ("key=" + Entry.getkey () + "and value=" + Entry.getvalue ()); 4 }

Java.util

Class abstractcollection<e> This abstract class gives the most basic implementation of the class collection interface, minimizing the work of the collection interface. Abstractlist, Abstractqueue, Abstractset, Arraydeque a truth.

Java.util

collections and Arrays are tool classes, and all methods are static. Collections a common method

public static <T> Boolean addall (collection<? super t> C, T ... elements) adds elements to Collection, Elements can be either one or an array.

Arrays also has a similar approach to public static <T> list<t> aslist (T ... a).

Java Iterator iterable Collection abstractcollection Map Relationship

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.