: Package test;import java.util.*;/*** @author Administrator**/ Public class Testhashset { Public Static void Main (String args[]) {hashsetNew hashsetlinkedlistNew linkedlistList.add ("List1");List.add ("List2");List.add ("List3");Hash.add ("hash Set1");Hash.add ("Hash Set2");Hash.add ("hash Set3");Hash.add ("hash Set4");Hash.add ("hash Set5");Hash.add ("hash Set6");Hash.addall (list);//The list added to the hash set is not present as a separate element, [List1, Hash Set6, LIST3, List2, hash set
Method One: Use the Arrays.aslist () methodString[] STRs = {"One", "one", "three"};listAttention:1) This method returns an array-based list view and does not create a list object, so the list cannot be added and deleted.Making modifications to the list Yes, it will also be modified to the array.2) The array is converted to a read-only list, using the Collections.unmodifiablelist () method to convert the array to list.3) Return to the list of deletions, using new ArrayList (Array.aslist (Array)).
design this program 'By using the nested implementations of map and map, the implementation code is as follows: Packagetest.day14;ImportJava.util.HashMap;ImportJava.util.Map;ImportJava.util.Scanner; Public classMapqiantaotest { Public Static voidMain (string[] args) {Scanner sc=NewScanner (system.in); HashMapNewHashmap(); Map.put (120, "36 gauge"); HashMapNewHashmap(); Map2.put (119, map); HashMapNewhashmapInteger, HashMap(); Map3.put (110, MAP2); while(true) {System.out.println ("Please enter
, but and HashTable not the same,TreeMap storage is closer to the same as a tree list, in the process of storing a Entry node will also be the Entry the left and right side of the node is saved with the parent node. , PS: If you need a more detailed understanding of The implementation of TREEMAP can query the red-black tree, because TreeMap is based on the red-black tree ( Red-black tree) is implemented. 4, WeakhashmapBasic functions and HashMap is the same, unlike HashMap , which is weakhashm
on. If the tab cannot be displayed, make sure the. vimrc file is set with the set lcs=tab:>-command, and make sure that your file has a tab, and if Expendtab is turned on, tab will be expanded to a space.Vim TutorialsOn UNIX Systems$ vimtutorOn a Windows system: Help Tutor: syntax lists syntax items that have already been defined: syntax clear clears the defined grammar rules: syntax case match casing sensitive, int and int will be treated as different syntax elements: syntax case ignore upperc
What is an array?An array is an unordered sequence of elements, and all elements in an array have the same type.Declaring an array variable:Int[] A; the size of the array is not part of the Declaration;To create an instance of an array:A=new Int[3];Initialize the array variable:Int[] A=new int[2]{1,2};Int[] a={1,2};Time[] schedule={new time, New Time (5,30)};To create an implicitly-typed array:var name=new[]{new {name= "John", age=44},new {name= "Diana", age=45}};To iterate over an array:You can
static globally unique new Integer (0) value as no valueEnumsetInternally using a bit vector implementation, an abstract class that cannot be created directly from the new keyword, you must create a set of the specified enumeration type using another factory method method similar to noneof. The object that is actually created is a subclass of Enumset Regularenumset or Jumboenumset.The specific subclass type is determined based on the number of enumerated values of the enumerated type being pass
synchronous, that is, thread-safe , relatively low efficiency, suitable for use in multi-threaded environment, and HashMap is not synchronized, relatively high efficiency, Advocated for use in single-threaded environments. 3). The default initial capacity of the HashMap is 0.75, and theload factor isthe default initial capacity of the Hashtable is one and the load factor is 0.75.Properties class Inherits the Hashtable class, representing a persistent set of properties. Properties can be saved
() Determines whether a string ends a string with a string: The Split () string is converted to a list ("A delimiter needs to be defined in parentheses") join () convert list to string "format: x=" | ". Join (list) format string: Format () {} Replace with placeholder {index} Replace with the specified index {name} is replaced by the specified name for example: My name is {} ' age is {} '. Format (parameter 1. ..., parameter n) print ("My name is%s-age is%s"% ("Yyh", "+")) print ("My name is {na
by simultaneous writing of multiple threads, but achieving synchronization requires a high cost, so Accessing it is slower than accessing ArrayList.3. LinkedList is used to store data in a linked list structure, which is suitable for dynamic insertion and deletion of data, and is slow in random access and traversal. In addition, there is no method get,remove,insertlist defined in the interface, specifically for manipulating the header and footer elements, which can be used as stacks, queues, an
. While it is certainly possible to add and remove Java.util.List as a queue at the opposite ends, the new queue interface provides additional ways to support adding, removing, and checking collections, as follows:
public boolean offer(Object element) public Object remove() public Object poll() public Object element() public Object peek()
Basically, a queue is a first in first out (FIFO) data structure. Some queues have size limits, so if you want t
Microsoft has added a new concurrent programming framework to the C # (4.0) framework, and we can now develop programs that support concurrent concepts in C #. One of the most annoying things in concurrent programming is how to synchronize data: avoid dirty reads and dirty writes, of course we can do it through lock technology, or we can use the concurrent collections that Microsoft provides to us, which provide trydo methods. The read/write operation
()Returns an array of traversed (key, value) tuples as a list
7
Radiansdict.keys ()Returns a dictionary of all keys in a list
8
Radiansdict.setdefault (Key, Default=none)Similar to get (), but if the key does not exist in the dictionary, the key is added and the value is set to default
9
Radiansdict.update (DICT2)Update the key/value pairs of the dictionary dict2 to the Dict
10
Radiansdict.values ()Returns all values in
, there is a solution to the problem of calculating floating-point numbers by using integer numbers, for example, we will enlarge the above floating-point number first Ten times into integer data, and then the calculation ends and then shrinks Ten Times:(8+ 7 + 6 + 9)/4/10 //0.75(6+ 8 + 7 + 9)/4/10 //0.75Summarize:
when using For : in loops, do not rely on the order in which they are traversed.
when using Object type to hold the data, you need to ensure that the data in it is unordere
, intersection, and difference operations. So, if you want to perform some normal collection operations on the keys of the collection, you can use the key view objects directly without first converting them to a set.The dictionary's items () method returns an element view object that contains (key, value) pairs. This object also supports collection operations and can be used to find out which two dictionaries have the same key-value pairs.Although the values () method of the dictionary is simila
, and clear methods for that collection). But if the iterator calls its own remove method, it is still legal.3.List interfaceThe Java.util package inherits the collection interface. Here are just a few important methods. Public Interface extends Collection{ AnyType get (int idx); AnyType Set (int idx, AnyType newval); void Add (int idx, AnyType x); void Remove (int idx); Listiteratorint poss);}View CodeIndex 0 is in the front segment of the table, size ()-1 represents t
types:eg:li=[1,2,3,4,4,3,2]s = Set (LI)-------at this time S is a set, with no weight.eg:li={1,2,3,4,3,2}D = {}.fromkeys (LI); ----------the weight of the dictionary.Collections, like dictionaries, are non-smooth and do not slice, index, duplicate, or support joins, but support actions such as iteration (for), member lookups, and so on.The increase, deletion and modification of a set:Added: s={1,3,4,5}S.add (9)-------------add elements directly to the collection via the Add () function.S1 = {"H
1. Array to Liststring[] City = {"Nanjing", "Shanghai", "Beijing"}; ListNote: The list size of the array conversion is fixed, the Add, remove operation cannot be performed, or the following exception is thrown:Citylist.add ("Xiamen"); Citylist.remove (2);If you want to control the list size, you can only add the elements in the array to the list ...2. List Goto Arrayobject[] Cityarray = Citylist.toarray (); for (Object X:cityarray) System.out.println (x);Note: Since the list is converted to
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.