Skip to content

Commit fc74587

Browse files
authored
Merge branch 'main' into add-approach-bob
2 parents 1802823 + 406af2a commit fc74587

File tree

37 files changed

+295
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

37 files changed

+295
-126
lines changed

.github/workflows/java.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
1919
- name: Set up JDK 1.17
20-
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b
20+
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b
2121
with:
2222
java-version: 17
2323
distribution: "temurin"
@@ -31,7 +31,7 @@ jobs:
3131
steps:
3232
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
3333
- name: Set up JDK 1.17
34-
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b
34+
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b
3535
with:
3636
java-version: 17
3737
distribution: "temurin"
@@ -47,7 +47,7 @@ jobs:
4747
- name: Test all exercises using java-test-runner
4848
run: bin/test-with-test-runner
4949
- name: Archive test results
50-
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
50+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b
5151
with:
5252
name: test-results
5353
path: exercises/**/build/results.json

.github/workflows/markdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
2121
- name: Lint markdown
22-
uses: DavidAnson/markdownlint-cli2-action@eb5ca3ab411449c66620fe7f1b3c9e10547144b0
22+
uses: DavidAnson/markdownlint-cli2-action@a23dae216ce3fee4db69da41fed90d2a4af801cf

concepts/switch-statement/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"Azumix"
55
],
66
"contributors": [
7+
"josealonso"
78
]
89
}

concepts/switch-statement/about.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,23 @@ Starting with Java 14 (available as a preview before in Java 12 and 13) it is po
147147

148148
You can find more information on enhanced switch [here][switch1], [here][switch2] and on the [oracle documentation][oracle-doc].
149149

150+
In addition, a feature called `Guarded Patterns` was added in Java 21, which allows you to do checks in the case label itself.
151+
152+
```java
153+
String dayOfMonth = getDayOfMonth();
154+
String day = "";
155+
return switch (day) {
156+
case "Tuesday" when dayOfMonth == 13 -> "Forbidden day!!";
157+
case "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" -> "Week day";
158+
case "Saturday", "Sunday" -> "Weekend";
159+
default -> "Unknown";
160+
};
161+
```
162+
163+
You can find more information on the switch expression on Java 21 [here][switch-on-Java-21]
164+
150165
[yield-keyword]: https://www.codejava.net/java-core/the-java-language/yield-keyword-in-java
151166
[switch1]: https://www.vojtechruzicka.com/java-enhanced-switch/
152167
[switch2]: https://howtodoinjava.com/java14/switch-expressions/
153168
[oracle-doc]: https://docs.oracle.com/en/java/javase/13/language/switch-expressions.html
169+
[switch-on-Java-21]: https://blog.adamgamboa.dev/switch-expression-on-java-21/#3-guarded-pattern

concepts/switch-statement/links.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@
1414
{
1515
"url": "https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html",
1616
"description": "oracle-doc"
17+
},
18+
{
19+
"url": "https://blog.adamgamboa.dev/switch-expression-on-java-21/#3-guarded-pattern",
20+
"description": "switch-on-Java-21"
1721
}
1822
]

exercises/concept/calculator-conundrum/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"jmrunkle"
55
],
66
"contributors": [
7+
"jagdish-15",
78
"sanderploegsma"
89
],
910
"files": {

exercises/concept/calculator-conundrum/.meta/src/reference/java/IllegalOperationException.java

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class IllegalOperationException extends RuntimeException {
2+
public IllegalOperationException(String errorMessage) {
3+
super(errorMessage);
4+
}
5+
6+
public IllegalOperationException(String errorMessage, Throwable cause) {
7+
super(errorMessage, cause);
8+
}
9+
}

exercises/concept/wizards-and-warriors-2/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"sougat818"
44
],
55
"contributors": [
6+
"jagdish-15",
67
"sanderploegsma"
78
],
89
"files": {

exercises/concept/wizards-and-warriors-2/.meta/src/reference/java/Character.java

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)