Skip to content

Commit

Permalink
Merge pull request #33 from trishagee/main
Browse files Browse the repository at this point in the history
  • Loading branch information
helenjoscott authored Dec 5, 2024
2 parents 8d93f73 + ea1fd54 commit d29a488
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
- name: Set up JDK 23
uses: actions/setup-java@v2
with:
java-version: 21
java-version: 23
distribution: 'temurin'
- name: Build Java examples with Maven
run: mvn -B verify --file java-samples/pom.xml
Expand Down
2 changes: 1 addition & 1 deletion .idea/dataSources.local.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion java-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<version>1.0-SNAPSHOT</version>

<properties>
<java.version>21</java.version>
<java.version>23</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

void main() {
System.out.println("Hello, World!");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.jetbrains.code.jdk22;

import com.jetbrains.entity.Order;

import java.awt.Point;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;

public class UnnamedVariables {
static int suggestReplacingUnusedVariableWithUnderscore(Iterable<Order> orders) {
int total = 0;
for (Order order : orders) // order is unused
total++;
return total;
}

static void demoUseOfUnderscore() {
var q = new ArrayBlockingQueue<Integer>(3, true, List.of(1, 2, 3));
while (q.size() >= 3) {
int x = q.remove();
int y = q.remove();
int _ = q.remove(); // z is unused
new Point(x, y);
}
}

static int demoUseOfUnderscoreInException() {
String s = "Some string";
try {
return Integer.parseInt(s);
} catch (NumberFormatException _) {
System.out.println("Bad number: " + s);
return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.jetbrains.code.jdk23;

public class PrimitiveTypesInSwitch {
private void type(Message x) {
switch (x.getStatus()) {
case 0 -> System.out.println("okay");
case 1 -> System.out.println("warning");
case 2 -> System.out.println("error");
default -> System.out.println("unknown status: " + x.getStatus());
}
}

private static class Message {
private int status;

public int getStatus() {
return status;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ public class Deprecation {
private void deprecationWarnings() {
Thread.currentThread().stop();

Thread.currentThread().countStackFrames();

final MyClass myClass = new MyClass();
myClass.deprecatedMethod();
}
Expand Down

0 comments on commit d29a488

Please sign in to comment.