JAVA List Collection

Source: Internet
Author: User
Tags set set

Why do I need a collection? What is the difference between a collection and an array?
A: The array is a linear sequence, so it can quickly access the other elements, once the capacity to build it is fixed, and in its life cycle can not be changed.
Collections store their elements as objects, and can dynamically change the size as needed.
--------------------------------------------
What are the collections in Java?
A: List, containing vectors, arraylist,linkedlist
Set, including HashSet, Linkedhashset, TreeSet
Map, including hashmap,hashtable
--------------------------------------------
What is the difference between list and set?
Answer: List is ordered. Element repeatable set is unordered, non-indexed, and no duplicates.
--------------------------------------------
What is the difference between ArrayList and vectors?
A: Vectors are thread-safe, but less efficient.
ArrayList is not thread-safe. But the efficiency is high.
--------------------------------------------
What do I need to be aware of deleting elements?
A: Deleting an element because the element that follows the delete element is automatically moved forward, so it can cause a bug in the program, so you want to remove it from the back.
--------------------------------------------
The elements in list allow repetition, how to go heavy?
A: After iterating through the list collection, assign to another list collection, which is then returned to the list collection by assigning a set set.
--------------------------------------------
What is the difference between the order of TreeSet and list?
A: Order in the list refers to the order in which the elements are placed, while TreeSet refers to the ordering of elements from small to large.
--------------------------------------------
The difference between collection and collentions?
Answer: Collection is a collection interface. The collection interface has many specific implementations in the Java class Library. The meaning of the collection interface is to provide a maximum unified operation for a variety of specific collections.
Collections is a wrapper class that contains a variety of static polymorphic methods related to set operations. This class cannot be instantiated, just like a tool class that serves the Java collection framework.
--------------------------------------------
What's the difference between HashMap and Hashtable?
A: HashMap is thread insecure, high efficiency, key, vaule allow NULL, but key cannot be duplicated.
Hashtable is thread-safe. less efficient. Key, Vaule not allowed to be null

JAVA List Collection

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.