进阶day06-Predicate的练习
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.inmind.functional_interface02;
|
||||
|
||||
/*
|
||||
数组当中有多条“姓名+性别”的信息如下,请通过Predicate接口的拼装将符合要求的字符串筛选到集合ArrayList中,需要同时满足两个条件:
|
||||
|
||||
1. 必须为女生;
|
||||
2. 姓名为4个字
|
||||
|
||||
分析:
|
||||
1.一个predicate判断是否是女生
|
||||
2.一个predicate判断名字是否长度为4
|
||||
3.创建集合,遍历数组中的字符串,满足条件的添加到集合中
|
||||
|
||||
*/
|
||||
public class Demo12 {
|
||||
public static void main(String[] args) {
|
||||
String[] array = { "迪丽热巴,女", "古力娜扎,女", "马尔扎哈,男", "赵丽颖,女" };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user