merge
This commit is contained in:
@@ -90,7 +90,7 @@ public class CollectionDemo {
|
||||
list.remove(0);// 从集合中删除指定位置的元素,并将其返回
|
||||
int size = list.size();// 长度
|
||||
boolean isEmpty = list.isEmpty();// 是否为空
|
||||
boolean contains = list.contains(Integer.valueOf(1));// 是否包含元素
|
||||
boolean contains = list.contains(1);// 是否包含元素
|
||||
// l.clear();//清除集合元素
|
||||
Set<Integer> s = new HashSet<>();// 无序
|
||||
s.add(111);
|
||||
@@ -118,7 +118,7 @@ public class CollectionDemo {
|
||||
/**
|
||||
* lambda表达式
|
||||
*/
|
||||
list.forEach(o -> System.out.println(o));
|
||||
list.forEach(System.out::println);
|
||||
//删除某元素
|
||||
list.removeIf(integer -> integer == 0);
|
||||
|
||||
@@ -150,7 +150,7 @@ public class CollectionDemo {
|
||||
/**
|
||||
* lambda表达式
|
||||
*/
|
||||
list.sort((o1, o2) -> o1 - o2);
|
||||
list.sort(Comparator.comparingInt(o -> o));
|
||||
|
||||
/*
|
||||
* 队列 队列也可以存放一组元素,但是存取元素必须 遵循:先进先出原则
|
||||
|
||||
@@ -34,7 +34,7 @@ public class LambdaDemo {
|
||||
// //遍历
|
||||
// Arrays.stream(arrays).forEach(System.out::println);
|
||||
list.forEach(System.out::println);
|
||||
lists.sort((o1, o2) -> o1 - o2);//升序排序,不需要收集
|
||||
lists.sort(Comparator.comparingInt(o -> o));//升序排序,不需要收集
|
||||
System.out.println("sort:" + lists.stream().sorted((o1, o2) -> o2 - o1).collect(Collectors.toList()));//排序
|
||||
System.out.println("map:" + lists.stream().map(o1 -> o1 * 2).collect(Collectors.toList()));//转换
|
||||
System.out.println("distinct:" + lists.stream().distinct().collect(Collectors.toList()));//去重(去重逻辑依赖元素的equals方法)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.xwbing.demo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
@@ -12,12 +10,7 @@ import java.util.concurrent.ExecutionException;
|
||||
*/
|
||||
public class demo {
|
||||
public static void main(String[] args) throws ExecutionException, InterruptedException {
|
||||
String s="001";
|
||||
Integer integer = Integer.valueOf(s);
|
||||
System.out.println(integer);
|
||||
List<Integer> list = new ArrayList<>();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
list.add(i);
|
||||
}
|
||||
int i = "222".compareTo("11111");
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user