Java String[]转List<String>
整理笔记:String [] 转 List<String>
String [] al = new String[]{"1","q","a","z"};
1、最差方案
List<String> b = new LinkedList<String>();
for(String c:al){
b.add(c);
}
b.forEach(System.out::println);
2、稍微聪明点的
#import java.util.Arrays;
List<String> listString = Arrays.asList(al);
listString.forEach(System.out::println);
3、1.8jdk新方法
#import java.util.stream.Collectors;
#import java.util.stream.Stream;
List<String> listStrings = Stream.of(al).collect(Collectors.toList());
listStrings.forEach(System.out::println);