把集合中字符串长度大于8的元素查找出来并组成一个新的集合
public class Demo2 {
public static void main(String[] args) {
// 把features集合中长度大于8的元素查找出来并组成一个新的集合
List<String> features = Arrays.asList("Lambdas", "Default Method", "Stream API", "Stream API", "Date and Time API");
ArrayList<String> list = new ArrayList<String>();
for (String strs : features) {
char[] cs2 = strs.toCharArray();
if(strs.length()>8){
list.add(strs);
}
}
for (String str:list
) {
System.out.println(str);
// System.out.println("结束");
}
}
}