Commit 33a9fb8
Solutions/generics/03 (#73)
* Update SchoolClass.java
In the loop condition, pupils.size() is re-evaluated in each iteration, and because the code removed pupils from the list inside the loop, the size of the list decreases with each iteration. This is not clean and because of this an exception occurred when trying to run the function with an even amount of pupils.
Furthermore the if condition to check if the size of the array is 1 needed also to be inside the loop for this solution.
* Update Exercise.java
Add example for even pupils
* Use while loop
---------
Co-authored-by: SteffenLm <33038091+SteffenLm@users.noreply.github.com>1 parent 47571e5 commit 33a9fb8
2 files changed
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
0 commit comments