interface Condition{
boolean test(int val
);
}
public class Main {
private static void printCondition(int[] list
,Condition cond
){
for(int val
:list
){
if(cond
.test(val
)){
System
.out
.println(val
);
}
}
}
public static void main(String
[] args
) {
int[] a
=new int[100];
for(int i
=0;i
<100;i
++){
a
[i
]=i
;
}
printCondition(a
, new Condition() {
@Override
public boolean test(int val
) {
return val
%3==0;
}
});
}
}
转载请注明原文地址: https://win8.8miu.com/read-1498808.html