Stream.of(arr).map(str -> Integer.parseInt(str)).forEach(str -> System.out.print(str));//map映射 类型转换
long count = Stream.of(arr).count();
Stream
Stream
stream流 传给下一个流(返回值是一个流)之后它就没有值了,不能再调用它,可以求它的哈希值....
Stream
***Socket Serversocket serve.accept socket.getInpu.... accept.getInpu.....
int len;
byte[] bytes = new byte[1024];
while ((len = inp.read(bytes)) != -1) {
System.out.println(new String(bytes));
}
//比较器
public static void main(String[] args) {
String[] strs = {"aaa","a","saas"};
Arrays.sort(strs, *so());
System.out.println(Arrays.toString(strs));
}
public static Comparator<String> *so() {
return (o1,o2) -> o1.length() - o2.length();
}
//消费者
Demo04 demo01 = new Demo04("张","50" ,"asda" );
Demo04 demo02 = new Demo04("王", "5","asd" );
Demo04 demo03 = new Demo04("李","15" ,"asa" );
Demo04 demo04 = new Demo04("赵","25" ,"ada" );
Demo04[] arr = {demo01,demo02,demo03,demo04};
s(arr,(name1) -> {
System.out.print(name1.getName());
},(name2) -> {
System.out.print(name2.getAge());
},(name3) -> {
System.out.println(name3.getAdd());
}
);
}
public static void s(Demo04[] demo,Consumer<Demo04> con1,Consumer<Demo04> con2,Consumer<Demo04> con3){
for (Demo04 demo04 : demo) {
con1.andThen(con2).andThen(con3).accept(demo04);
}
//生产者
public static void main(String[] args) {
String s = s(() -> {
return "是";
});
System.out.println(s);
}
public static String s(Supplier<String> pp){
return pp.get();
}
**延迟方法**:返回值类型都是Stream接口自身,因此可以支持链式操作。
**终结方法**:返回值就不是Stream接口自身,因此不能再进行链式操作。比如:count方法和forEach方法
浙公网安备 33010602011771号