当前位置:网站首页>Guava common collection tool classes
Guava common collection tool classes
2022-06-25 05:38:00 【Which floor do you rate moto】
- Sets Tool class operations Set aggregate
- Combine , Delivery and , Difference set , Decompose all subsets in the set , Find the Cartesian product of two sets
public class sets {
public static void main(String[] args) {
Set<Integer> set1 = Sets.newHashSet(1,2,3,4);
Set<Integer> set2 = Sets.newHashSet(4,5,6);
// Combine
Set<Integer> integerSet = Sets.union(set1,set2);
System.out.println(integerSet);
// intersection
Set<Integer> intersectionSet = Sets.intersection(set1,set2);
System.out.println(intersectionSet);
// Difference set : The element belongs to set1 It doesn't belong to set2
Set<Integer> differenceSet = Sets.difference(set1,set2);
System.out.println(differenceSet);
// Relative difference set : Belong to A It doesn't belong to B, Belong to B It doesn't belong to A
Set<Integer> symmetricDifference = Sets.symmetricDifference(set1,set2);
System.out.println(symmetricDifference);
// Decompose all subsets in the set
Set<Set<Integer>> powerSet = Sets.powerSet(set1);
System.out.println(JSON.toJSON(powerSet));
// Cartesian product of two sets
Set<List<Integer>> cartesianProduct = Sets.cartesianProduct(set1,set2);
System.out.println(JSON.toJSON(cartesianProduct));
}- Lists Tool class operations List aggregate
- reverse , Split
public class lists {
public static void main(String[] args) {
List<Integer> list = Lists.newArrayList(1,2,3,4,5,6,7);
//3 individual 3 Split up : Support with 3 An interface for querying a group of order numbers
List<List<Integer>>lists = Lists.partition(list,3);
System.out.println(lists);
// reverse
List<Integer> integerList = Lists.reverse(list);
System.out.println(integerList);
}
}边栏推荐
猜你喜欢
![[OSPF routing calculation (class I LSA router, class II LSA network, and class III LSA sum net)] -20211228-30](/img/c7/e38a7a5cd4c1e4105c3f3f246276c6.jpg)
[OSPF routing calculation (class I LSA router, class II LSA network, and class III LSA sum net)] -20211228-30

Multithreading and thread pool
![H5 canvas drawing circle drawing fillet [detailed explanation]](/img/6f/a33a323b6cd0918066e8b71a22d841.jpg)
H5 canvas drawing circle drawing fillet [detailed explanation]

Monkey test of APP automation

UVA816 Abbott’s Revenge

The article is on the list. Welcome to learn

Only these four instructions are required to operate SQL data
Learn the interface test, see it is very good, and make a note

How to add an external header file in vs?

Penetration test - right raising topic
随机推荐
Semantic segmentation fcns in the wild: pixel level adaptive and constraint based adaptation
Go Context - Cancelation and Propagation
[relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear
Deeply understand the characteristics of standard flow and off standard elements
Dynamic programming example 2 leetcode62 unique paths
A brief talk on media inquiry
Baidu ueeditor set toolbar initial value
Enhanced paste quill editor
On Transform
Double recursion in deep analysis merge sort
2.20 learning content
By inserting a section break, the word header, footer, and page number can start from any page
Five simple data types of JS
Go Methods and Interfaces
cuda编译报错
Handwritten promise all
The construction and usage of wampserver framework
Mobile number regular expression input box loses focus verification
Native JS high risk reminder pop-up code snippet, "are you sure you want to do this?" and "it cannot be recovered after deletion. Do you want to continue“
Penetration test - right raising topic