Java Collection List, Set, Map summary + HashMap/Hashtable difference, hashmaphashtableList: (ordered, can be repeated) through the subscript index ---- ArrayList variable array, random search ---- random List linked List, insert and delete at any location faster ---- Vector efficiency is lower than arraylist, but can
------Java Training, Android training, iOS training,. NET training, look forward to communicating with you! -------First, List collectionThe list collection represents an ordered, guest-repeating collection of elements in which each element has its corresponding sequential index. ListCollections allow you to use duplicate elements, which can be indexed to access
+ ":" +temp.name); Course C2=NewCourse ("2", "C language"); Coursestoselect.add (0, C2);//another Add () method that is overloaded in the list to specify where the element is addedCourse Temp2 = (Course) coursestoselect.get (0); System.out.println ("Added course:" + temp2.id + ":" +temp2.name); Coursestoselect.add (C1);//elements in list can be repeatedCourse temp0 = (Course) coursestoselect.get (2); Syste
Heart in Shandong body in Wu, floating Peng Jianghai diffuse sigh sigh.If he then Lingyun Zhi, dare laugh Huang Chao not husband.--Water MarginFirst on the source code, LinkedList class:1 Private Static classNode {2 E Item;3NodeNext;4Nodeprev;5 6Node (nodenext) {7 This. Item =element;8 This. Next =Next;9 This. prev =prev;Ten } One}The Java list defines an inner
Eliminate list duplicate valuesJava code
public void Removeduplicate (List list) {
HashSet h = new HashSet (list);
List.clear ();
List.addall (h);
}
Intersection:Java code
List.retainall (Arrays.aslist (arr)); In the list is t
time of execution, so there is no error at compile time, and in order to solve such errors, we should define
List
The order here is not to say that after the list is defined, the elements inside are sorted in order, but in the order in which they are inserted into the list. In the list definition, we want to use the
1, this program realizes the chain-type storage structure of linear table. The implemented list has two pointers, one always points to the first node in the list, and the other pointer always points to the last node in the list.The tail pointer is set because, when the element is inserted at the end of the list, the last element of the linked
First, MAP1. Map and HashMapMap is an interface, HashMap is an implementation class of map, so it can be defined as follows:Mapcannot be defined as follows, because an interface cannot be instantiated:Map2. The traversal of map can be referred to:4 ways to traverse a map object in Java
Second, List1. List and ArrayListList is an interface, ArrayList is an implementation class for the
Reference Blog: HTTPS://WWW.JIANSHU.COM/P/9FE8632D0BC2About Stream
Java 8 introduces a new stream API. This stream differs from the I/O stream in that it is more like a collection class with iterable, but behaves differently from the collection class.
Stream is an enhancement to the functionality of a collection object, focusing on a variety of very convenient, efficient aggregation operations for collection objects, or large-scale data m
The Java list interface has 3 implementation classes, ArrayList, LinkedList, and vectors, which are used to store multiple elements, maintain the order of elements, and allow elements to be duplicated.The differences between the 3 specific implementation classes are as follows:1. ArrayList is the most commonly used list implementation class, implemented internall
the listThere are at least three ways to traverse after JDK1.5: ForEach, iterator, for loop.Package Bupt.xiaoye.charpter2.list;import Java.util.arraylist;import Java.util.iterator;import java.util.List; public class Testfor {public static void Testforeach (List list) {Object Temp;for (object t:list) temp = t;} public static void Testfor (
Common Operations on the List set in Java, javalist set
Directory:
Note: the code in the content is correlated.
1. Add, retrieve, and delete elements in the list;
The add method is :. add (e); The Obtaining method is :. get (index); the deletion method is :. remove (index); Delete by index ;. remove (Object o); Delete according to the element content;
The container class can greatly improve the programming efficiency and programming capability. In Java2, all containers are re-designed by SUN's Joshua Bloch, enriching the functions of the container class library.The Java 2 Container class library is used to save objects. It is divided into two types:Collection-a group of independent elements that generally follow certain rules. The List must maintain the
: AlthoughSetwithListhas been implementedCollectioninterfaces, but they are implemented in a very different way. ListBasically, they are all based onArrayas a basis. ButSetit is inHashMapon the basis of this, which isSetand theListthe fundamental difference. HashSetThe storage method is to putHashMapin theKeyas aSetthe corresponding storage item, and this is why inSetcan not be like inListThe root cause of the duplicate entry, asHashMapof theKeythere is no repetition. linkedhashset: HashS
list has two ways to convert to array:
Public object[] ToArray ();This method returns all the elements in the list to an array of the same size, and all elements in the array are of type object.
Public This method returns all the elements in the list to an array of the same size, and all elements in the array are of type T.
The
Mailing list services are often used to provide an e-mail-based discussion environment for a workgroup, through which subscribers discuss issues of common interest.
The sample program provided in this article listserver is a simple mailing list forwarding server that reads new messages from a specified account and sends them to all subscribers. The Java Mail API
Use JavaScript to implement the Java List function (for example ). For more information, see.
The Code is as follows:
/*** Js simulates List in java*/
Var list = new Array ();
/*** Add* @ Param {Object} object*/Function add (object ){L
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.