Set set, List, Set set list

Source: Internet
Author: User
Tags set set

Set set, List, Set set list

Collection System: Collection and Map Interfaces

Objects of different storage quantities cannot store basic data types. For example, basic data types are automatically packed.

========================================================== ================

Sub-interfaces of Collection: Set interface and List Interface

Implementation classes of the Set interface: HashSet, javashashset, and TreeSet

Implementation classes of the List interface: ArrayList, sorted List, and Vector

========================================================== ======

Implementation classes of the Map interface: HashMap, TreeMap, and Hashtable

========================================================== ========

Features:

Collection: indicates the set of objects that are not stored in the order of addition. The elements in the set can be repeated, that is, the "unordered and repeatable" set.

Set: an unordered and non-repeating Set of elements-similar to a high school "Set"

List: an ordered and repeated set of elements --- "dynamic" Array

Map: a set of key-value pairs with Mappings

========================================================== ==========

1. Before Java 5, the Java set will lose the Data Types of all objects in the container and treat all objects as objects. After the generic type is added to Java 5, the Java Collection can remember the Data Type of objects in the container.

2. A foreach loop is also called an enhanced for loop.

For (Object obj: collection ){
System. out. println (obj); // Object: Element type to be traversed; obj: name of the element after traversal; collection: collection Object to be traversed
}

1 @ Test 2 public void test5 () {3 String [] str = new String [5]; 4 for (String myStr: str) {5 myStr = "xiaobing "; 6 System. out. println (myStr); 7} 8 for (int I = 0; I <str. length; I ++) {9 System. out. println (str [I]); 10} 11} 12 13 =================================14 results: 15 xiaobing16 xiaobing17 xiaobing18 xiaobing19 xiaobing20 null21 null22 null23 null24 null

 

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.