LeetCode brush some of the problems encountered in the knowledge

Sting array and char conversion

String s;
char array[]=s.toCharArray();
s=String.vauleOf(array);
或者 new String(array)
HashMap 与HashSet

hashMap-value is the key
hashSet key is
selected by the hashcode bucket is then judged equal () is equal to decide whether to join
http://www.importnew.com/6931.html
http://www.importnew.com/21841.html
hashmap depth torture: http://www.importnew.com/7099.html
hashmap Hashtable difference http://www.importnew.com/7010.html
hashSet use:

1,HashSet是set接口的实现类,也是我们最常用的set集合
储存的是无序,唯一的对象
由于是无序的所以每组数据都没有索引,很多list可用的方法他都没有
凡是需要通过索引来进行操作的方法都没有
所以也不能使用普通for循环来进行遍历,只有加强型for和迭代器两种遍历方法

例如:
get(i);
set(int index,Object o);
remove(int index);
等需要用索引来操作的方法都没有;

2.HashSet的各种方法:
增加
add(null);
	
删除
remove(news);
	
对比查找
contains(news);
--------------------- 
作者:jinqianwang 
来源:CSDN 
原文:https://blog.csdn.net/jinqianwang/article/details/80030060 

When using tools == Arrays.asList () == convert the array into a set, which can not be used to modify a set of related methods, it add / remove / clear method throws exception UnsupportOperationException

Integer[] data = {1,2,3,4,5};
List list = Arrays.asList(data);
------------------------------------
private final static HashSet<Character> vowels=new HashSet<>(Arrays.asList('a','e','i','o','u','A','E','I','O','U'));

java List interface class
First, look at these two types of implements List interface, and List interfaces to achieve a total of three categories, namely ArrayList, Vector and LinkedList. List for storing a plurality of elements, it is possible to maintain order of the elements, and the elements allowing repeated. Related concrete implementation class distinction 3 as follows:

  1. List ArrayList is the most common implementation class, the interior is achieved through an array of elements that allows for fast random access. The disadvantage is that the array can not have a space between each element when the array size does not satisfy the need to increase storage capacity, it is necessary to speak has been copied to the new array of data storage space. When inserting or deleting an element from the intermediate position of ArrayList, the array is required to copy, move, the cost is relatively high. Therefore, it is suitable for random search and traversal, not suitable for insertion and deletion.
  2. Vector and ArrayList, just as implemented by the array, except that it supports synchronous threads that only one thread at a time can write Vector, avoid multi-threading while writing the inconsistency caused, but synchronization requires a very high cost Therefore, it is slower than access access ArrayList.
  3. LinkedList is a linked list data structure stored, it is suitable for dynamic insertion and deletion of data, random access and traverse slower. In addition, he also provides a method for the List interface not defined specifically for headers and footers operating elements, can be used as stacks, queues, queue and bidirectional use.
    View the Java source code and found that when the size of the array is not enough, you need to re-establish the array, and then copy the elements into the new array, the array of different sizes extend ArrayList and the Vector.
List of ArrayList super full use Raiders:
https://blog.csdn.net/qq_33505051/article/details/78967362
String ar[]= {"dsds","sdfs","sdd"};
List<String>vv=new ArrayList<String>(Arrays.asList(ar));
Integer am[]= {1,2,3};
List <Integer>ccc=new ArrayList<Integer>(Arrays.asList(am));

Remember List package is introduced import java.util.List; in.

Published 39 original articles · won praise 6 · views 10000 +

Guess you like

Origin blog.csdn.net/poppyl917/article/details/89370766