File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .util .List ;
2+
3+ /**
4+ *
5+ */
6+ public class Challenge_20 {
7+
8+ public static void main ( String [] args ) {
9+ List <Simpson > list = List .of (new Simpson ("Homer" , 35 ),
10+ new Simpson ("Margie" , 35 ),
11+ new Simpson ("Bart" , 10 ),
12+ new Simpson ("Lisa" , 8 ));
13+
14+ list .stream ()
15+ .filter (simpson -> simpson .getName ().equals ("Bart" ))
16+ .filter (simpson -> simpson .getAge ()>9 )
17+ .findFirst ();
18+ }
19+
20+ //Homer Margie Bart 10
21+ private static class Simpson {
22+ private String name ;
23+ private int age ;
24+
25+ public Simpson ( String name , int age ) {
26+ this .age =age ;
27+ this .name =name ;
28+ }
29+
30+ public String getName () {
31+ System .out .println (name );
32+ return name ;
33+ }
34+
35+ public int getAge () {
36+ System .out .println (age );
37+ return age ;
38+ }
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments