1 Packagecom.jdk7.chapter4;2 3 Importjava.util.ArrayList;4 Importjava.util.LinkedList;5 Importjava.util.List;6 ImportJava.util.ListIterator;7 ImportJava.util.Stack;8 ImportJava.util.Vector;9 /**Ten * List of forms of collections in Java (sequential allow repetition) One * List of three forms of expression ArrayList, Vector, LinkedList A * where stack extends Vector - * Another: The list of Listiterator can manipulate the listing elements - * @author
server is the primary or the server> Db.runcommand ({"IsMaster": 1}){"IsMaster": true,"Maxbsonobjectsize": 16777216,"Maxmessagesizebytes": 48000000,"Maxwritebatchsize": 1000,"LocalTime": Isodate ("2017-12-27t13:45:21.228z"),"Maxwireversion": 5,"Minwireversion": 0,"ReadOnly": false,"OK": 1}7 Listcommands: Returns all commands that can be run on the server8 listdatabases: list all databases on the server9 Ping: detects if the link to the server is normal> Db.runcommand ({"Ping": 1}){"OK": 1}10Fix
");List.add ("zz");Sort by using the Sort methodCollections.sort (list);SOP (list);int Index=collections.binarysearch (list, "oo");SOP (index);}Take maximum valuepublic static void Maxdemo (){ListList.add ("ABCD");List.add ("AAA");List.add ("Z");List.add ("KKKK");List.add ("QQ");List.add ("zz");Sort by using the Sort methodCollections.sort (list);SOP (list);Use the Max method to take the maximum value.String Max
string and select 100Output all different strings in descending order and the number of repetitionsSimple sort of selectionbelong to select sort22 Compare size, find the extremum (maximum or minimum) is placed in a fixed position, this fixed position generally refers to theOne endResults are sorted in ascending and descending orderThe callout is a two-element method, in which the judgment Maxima are exchanged with the minimum value, and the optimization is added to determine whether the sorting
A set is composed of independent data items with common features. Through a set, we can use the same call code to process all elements of a set, instead of processing each item separately .. . Net collections such as (System. array class and System. collections namespace) array, list, queue, stack, hash table, dictionary, and even (System. data) DataSet, able, and the generic version (System.
method List4.2 use the stream () in Java8, filter (), collect () to write the code with the same 4.1, and test (to show the test data). When building a test collection, in addition to the normal student object, add some null to the collection, and the method you write should handle the null instead of throwing an exception. (: The school number appears) 5. Generic class: Generalstack jmu-java-05-collection GeneralStack5.1 Generalstack interface Code 5.2 combined with the previous work in the ar
the use of tool class collectionsimport java.util.arraylist;import java.util.collections;import Java.util.Comparator ;p Ublic class Collectionsdemos {public static void main (string[] args) {//TODO auto-generated method StubarraylistTo run the program:Gets the longest element in the collection, String max = Collections.max (al,new mycomparalength ()); System.out.println ("The longest element in the collection is:" +
One, What is LINQ
LINQ is the abbreviation for Language Integrated query (language integration queries). It is an important feature introduced by Microsoft in. NET 3.5. Since it was introduced by Microsoft, the corresponding programming is naturally the C # and Visual Basic languages.
The role of 1,LINQ
Let's use the same API (SQL-like syntax to query) to manipulate different data sources. For example, SQL Server, Oracle, XML, and data collections
Over the past few days, I 've learned Kent Beck's implementation patterns, probably because I just finished reading design patterns and thought the author's language was too casual, design patterns is more logical.
The so-called implementation mode also lacks some programming skills. From the perspective of the design mode, it is just a trick.
In addition, the book is far-fetched in many places. Maybe because I am not a Java programmer, a lot of content in the book cannot be understood, but I st
I. Let's talk about it first.ArrayOfInsufficient(You can also saySetDifferences from arrays ):
1. arrays are fixed in size and cannot be scaled. Although the generic method system. array. Resize can reset the array size, this method re-creates an array with the new size and initializes it with elements of the old array. Then the previous array will be discarded! The set is variable-length.
2. the array must declare the element type. The element type of the Collection class is object.
3. the read
Apache Commons CollectionsTags: collectionsapachehashmapcommandobjectjavadoc 2012-05-09 10:13 1070 people read Comments (0) Favorites Report Category: Java Programming (74)
Directory (?) [+]Original Http://blog.csdn.net/sunjavaduke/archive/2008/03/24/2214806.aspx This paper briefly introduces the content of collections frame in Apache Commons. This article is mainly based on the Apache official website overview, userguide and Javadoc translation. If t
Tags: choose detail ted Combo mem ant max mapping evel public class Linq{Mxsicedatacontext Db = new Mxsicedatacontext (); LINQ to SQLCount/sum/min/max/avg Count public void Count (){Description: Returns the number of elements in the collection, returns an INT type, and no delay. The generated SQL statement is: SELECT COUNT (*) from Poor performance in simple form var count = Db.MXSMemeber.Count (); With con
The counter data structure is used to provide technical functions. it is similar to the built-in dictionary structure in Python. here we use a few small examples to briefly master the usage of the counter structure in the Python Collections module: counter is a special dictionary, which is mainly used for counting. The key is the item to be counted, and the value is the number.
from collections import Cou
list
Meta-group
Can contain different types of objects, but is immutable, can not be added and subtracted elements, with () to define eg:atuple= (123, ' abc ', 4.56,[' inner ', ' list '],7-9j)
1.tuple (obj): Converts the object obj to a tuple object, and obj can be any string or List 2. The Del,cmp,len,max,min method for lists also applies to tuple, but because Ganso is immutable, substitution, addition, sorting, etc. are not
C # use of common collections (reproduced ),
Most Collections are in the two namespaces System. Collections and System. Collections. Generic. Specifically, System. Collections. Generic is used for Generic sets.
The Collection types of specific types are located in System.
First, counter (Counter)Counter is a supplement to the dictionary type that is used to track the number of occurrences of a value.Note: Because counter inherits from the Dict class, it has all the functions of the Dict class1 Import Collections 2 C1 = collections. Counter ('skdhflsdkngsnlknvdlfb')3print(C1)Counter1, __missing__ (self, key) for non-existent elements, the return counter is 0Import COLLECTIONS
customizing and extending Java Collections
For many Java developers, the Java collections API is a very needed alternative to standard Java arrays and all their drawbacks. It is not wrong to associate collections mainly with ArrayList, but for those who have the spirit of exploration, this is just the tip of the iceberg of c
I. Ordering of dictionary elementsDict.keys (), Dict.values (), Dict.items ()It's a good idea to sort by combining Max, Min, sorted,zip , and also note how the dictionary lambda operation does not use zip :Price = { ' a ': 1, ' B ': 2, ' C ': 3}# The value of multiple keys simultaneously takes the form of a tuple comparison, in practical application Note min_p = min (Zip (price.values (), Price.keys ())) max_p =
find the maximum value in the array, the plot steps are as follows: User input array: (A1,A2,A3,A4) contains all the sub-arrays of the first element {(A1), (A1,A2), (A1,A2,A3), (A1,A2,A3,A4)} contains all the sub-array collections of the second element {(A2), (A2,A3), A2,A3, A4)} contains all the sub-array collections {(A3) of the third element, (A3,A4)} all the sub-array sets {(A4)} containing the fourth
is, the List is rearranged based on the input of the random source, which has the same probability (assuming that the random source is fair). This algorithm is very useful in implementing a game of chance. For example, it can be used to mix a List of card objects that represent a deck of cards. In addition, it is also useful when generating test cases.Collections.shuffling (list)4) Inversion (Reverse)Use the reverse method to sort the specified list in descending order based on the natural orde
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.