Stream常见的生成方式

package pagckage;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

public class StreamDemo {

private static final String Integer = null;

public static void main(String[] args) {
// TODO Auto-generated method stub
//list set集合生成流的方法
List<String> list=new ArrayList<String>();
Stream<String> liststream= list.stream();
Set<String> set =new HashSet<String>();
Stream<String>setstream= set.stream();
//map集合间接得到生成流
Map<String,Integer>map=new HashMap<String,Integer>();
Stream<Integer> valuesstream=map.values().stream();
Stream<String>keystream=map.keySet().stream();
//数组可以通过Stream接口的静态方法of(t.....values)生产流
String []str= {"hello"};
Stream<String>strstream=Stream.of(str);
Stream<String>strsramStream=Stream.of("hello","word");
Stream<Integer>intstream=Stream.of(10,20);

}

}

上一篇:mysql 函数


下一篇:day 12