Collection. A sequence of independent elements that obey one or more rules. The list must save the element in the order in which it was inserted, and set cannot have duplicate elements. Map. A pair of key-value pairs of objects that allow keys to be used to look up values. There are 2 types of lists: basic ArrayList, longer than random-access elements, but slower when inserting and removing elements in the middle of a list. LinkedList, it provides opt
threads,Analysis of the deadlock problem.
Javaapi detailed
Javaapi Introduction, String and StringBuffer, various basic data type wrapper classes, System and runtime classes, date and Datefomat classes, and so on.Common collection classes are used as follows: Java collections Framework:collection, set, List, ArrayList, Vector, LinkedList, HashSet, TreeSet, Map, HashMap,TreeMap, iterator, en
Two main interfaces: collection and mapThree main categories: collection (set), list, mapping (map)1. Collection: No duplicate objects, no specific sort method2. List: objects are sorted by index location and can have duplicate objects3. Mapping: There is a key object and a value object, the key is not repeatable, the value can be repeatedHashtable and HashMap differences1 HashMap is not thread-safe2 Hashta
1.map and Map.entery differencesI think a lot of people misunderstand these two classes, or not very flexible application, let me briefly explain my understanding (for reference only).→map: No matter, learn Java, whether it is a bird or an old cow have knocked to knock, is a set of key-value pairs of classes, belonging to the thread is not safe, about the
all methodsSystem.out.println ("-linkhashmap--Features: Orderly!" ( The order here is not meant to be sorted! Instead, it is returned in the order in which it was inserted) non-thread safe, the parent class HashMap allow null Key/value "); Mymap.testlinkedhashmap ();//consistent with the implementation of HashMap, the only difference is the use of a two-way loop linked list, adding before pointers, so you can easily find the previous node to achieve
About the initialization of the Java double brackets is usually very convenient, especially in the constant file, there is no substitute. As shown below:Map map = new HashMap () { {Put ("Name", "Unmi"); Put ("QQ", "1125535"); }};The benefits are clear at a glance. Here's a list of the disadvantages of this approach, and if the object is to be serialized, it can cause serialization to fail.1. This is the way
/value" pairs ". Example: an object of a person: {"name": "", "Age": 24} 2. An array is an ordered set of values. (1) An array starts with "[" (left brackets) and ends with "]" (right brackets. (2) Use commas (,) to separate values. Example: A group of students {"student": [{"name": "Xiao Ming", "Age": 23 },{ "name": "", "Age": 24}]} Note: This Json object includes a student array, and the value in the stud
:30 Value:serveExplain the above code:(1) Purpose: Generate a set of (numbers, strings) map, numbers and strings are random(2) We need to assemble the class Pair, because we need to populate the Map,pair key and value we are all labeled final, such aspects of use.(3) Lettergenerator implement generator, then assemble the desired object into pair(4) Mymap inherits HashMap, expands new constructor(5) A new
Java hash and hash code discussion, simple HASHMAP implementation hash map run a variety of operation display columnsPackage org.rui.collection2.maps;/** * Hash and hash code * Link the soil-extraction object to the predicted object, * @author Lenovo * *///Groundhog public class Groundhog {protect Ed int number;public Groundhog (int n) {number=n;} @Overridepublic String toString () {return "Groundhog #" + N
mappings is almost identical to the preceding example, except with the different element and attribute names (
Bag mappingBag is a Java collection storage element that does not need to care about the order, but allows repeating elements in the list. Bag is a random grouping of objects in the list.
The collection collection is mapped to The RDBMS table and the Pojo class in the following
static void main ( String[] args) {set4. Iterator Interfaceiterator is the standard operation of the collection output.Iterator is a collection of specialized iterative output interfaces that iterate over the elements to determine whether they have content or, if anything, take the content out.For a concrete example, see the example above.5. Map InterfaceMap is
same way and in a highly interoperable manner.3. The class set must be easy to expand and modify. To achieve this goal, the class set framework is designed to contain a set of standard interfaces.Explanations of the same manner and height:An array of dynamic objects implemented as a class in the operation of a class set, so that all forms of operation are the same for any object. For example, add content must use the Add () method.Height generally re
The Hashcode () method of object in Java is not overridden, then the Hashcode () method returns the memory address ...
The ToString () method, as defined by the default object object, returns the Hashcode () return value of the package name + class name +@+16.
In our actual development, for example, the author defines a Java Bean object, and if I put it into the
problem domain in this article and explained some implementation details.Use Java generic ing to map different value types
For example, you need to provide the context of an application, which can bind a specific key to any type of value. Using String as the HashMap of the key, a simple type safe implementation may be as follows:
1234567891011121314
private string Tel; // The first phone number private string teltwo; // The second phone number public address () {} Public Address (string Street, string city, int zip, string Tel, string teltwo) {This. street = Street; this. city = cityw.this.zip = zip; this. tel = Tel; this. teltwo = teltwo;} Public String getstreet () {return Street;} public void setstreet (string Street) {This. street = Street;} Public String getcity () {return city;} public void setcity (string city) {This. city = city;}
does not refer to the natural order, but the order in which the elements are added is inconsistent with the order of the elements.------------------|HashSetThe bottom layer is for a hash table to support,Features: storage speed block------------------|TreeSetThe underlying is implemented using a red-black tree (binary tree) data structure that is not synchronized (that is, thread insecure) and cannot be shared among multiple threads, but can be synchronized using the Synchroinzedmap () method.f
) map, numbers and strings are random(2) We need to assemble the class pair. Due to the need to populate Map,pair's key and value we are all labeled final. Used in this way.(3) Lettergenerator realizes the generator, then assembles the desired object into a pair(4) Mymap inherits HashMap, expands new constructor(5) through the Putall or Collections.addall method inside the
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.