File tree Expand file tree Collapse file tree 3 files changed +31
-31
lines changed
Expand file tree Collapse file tree 3 files changed +31
-31
lines changed Original file line number Diff line number Diff line change 11import java .util .ArrayList ;
22
33public class FilteredAdultStudents {
4- private ArrayList <Student > students ;
4+ private ArrayList <Student > students ;
55
6- public FilteredAdultStudents () {
7- this .students = new ArrayList <>();
8- }
6+ public FilteredAdultStudents () {
7+ this .students = new ArrayList <>();
8+ }
99
10- public void add (Student student ) {
11- if (student .age > 18 ) {
12- this .students .add (student );
13- }
10+ public void add (Student student ) {
11+ if (student .age > 18 ) {
12+ this .students .add (student );
1413 }
14+ }
1515
16- public void printStudents () {
17- this .students .forEach ((student ) -> System .out .println (student ));
18- }
16+ public void printStudents () {
17+ this .students .forEach ((student ) -> System .out .println (student ));
18+ }
1919}
Original file line number Diff line number Diff line change 11import java .util .ArrayList ;
22
33public class FilteredTeenStudents {
4- private ArrayList <Student > students ;
4+ private ArrayList <Student > students ;
55
6- public FilteredTeenStudents () {
7- this .students = new ArrayList <>();
8- }
6+ public FilteredTeenStudents () {
7+ this .students = new ArrayList <>();
8+ }
99
10- public void add (Student student ) {
11- if (student .age < 18 ) {
12- this .students .add (student );
13- }
10+ public void add (Student student ) {
11+ if (student .age < 18 ) {
12+ this .students .add (student );
1413 }
14+ }
1515
16- public void printStudents () {
17- this .students .forEach ((student ) -> System .out .println (student ));
18- }
16+ public void printStudents () {
17+ this .students .forEach ((student ) -> System .out .println (student ));
18+ }
1919}
Original file line number Diff line number Diff line change 11public class Student {
2- public String name ;
3- public int age ;
2+ public String name ;
3+ public int age ;
44
5- public Student (String name , int age ) {
6- this .name = name ;
7- this .age = age ;
8- }
5+ public Student (String name , int age ) {
6+ this .name = name ;
7+ this .age = age ;
8+ }
99
10- public String toString () {
11- return this .name + " " + this .age ;
12- }
10+ public String toString () {
11+ return this .name + " " + this .age ;
12+ }
1313}
You can’t perform that action at this time.
0 commit comments