diff --git a/README.md b/README.md index 469f644..aca3c3a 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,9 @@ Each challenge has its **solutions**, its **instructions** and **input/output ex ### ✅ Programming languages available - [C/C++ (gcc)](https://gcc.gnu.org/) -- [C# (.NET Core)](https://docs.microsoft.com/en-us/dotnet/csharp/) +- [C# (.NET)](https://docs.microsoft.com/dotnet/csharp/) - [Dart](https://dart.dev/) +- [Java (OpenJDK)](https://openjdk.java.net/) - [JavaScript/TypeScript (Node.js)](https://nodejs.org/) - [Python](https://www.python.org/) - [Rust](https://www.rust-lang.org/) diff --git a/challenges/hello-world/solutions/java/function/README.md b/challenges/hello-world/solutions/java/function/README.md new file mode 100644 index 0000000..2a5870e --- /dev/null +++ b/challenges/hello-world/solutions/java/function/README.md @@ -0,0 +1,3 @@ +# hello-world/java/function + +Created by [@Divlo](https://github.com/Divlo) on 24 June 2021. diff --git a/challenges/hello-world/solutions/java/function/Solution.java b/challenges/hello-world/solutions/java/function/Solution.java new file mode 100644 index 0000000..bede282 --- /dev/null +++ b/challenges/hello-world/solutions/java/function/Solution.java @@ -0,0 +1,12 @@ +import java.util.Scanner; + +public class Solution { + public static void main(String[] args) { + String line; + Scanner scanner = new Scanner(System.in); + while(scanner.hasNextLine()) { + line = scanner.nextLine(); + System.out.println("Hello, " + line + "!"); + } + } +} diff --git a/cli/services/GitAffected.ts b/cli/services/GitAffected.ts index eae3200..533914b 100644 --- a/cli/services/GitAffected.ts +++ b/cli/services/GitAffected.ts @@ -6,7 +6,7 @@ import { Solution } from './Solution' const git = simpleGit() const solutionsRegex = new RegExp( - /challenges\/[\s\S]*\/solutions\/(c|cpp|cs|dart|javascript|python|rust|typescript)\/[\s\S]*\/(solution|Solution).(c|cpp|cs|dart|js|py|rs|ts)/ + /challenges\/[\s\S]*\/solutions\/(c|cpp|cs|dart|java|javascript|python|rust|typescript)\/[\s\S]*\/(solution|Solution).(c|cpp|cs|dart|java|js|py|rs|ts)/ ) class GitAffected { diff --git a/templates/docker/java/Dockerfile b/templates/docker/java/Dockerfile new file mode 100644 index 0000000..5f75948 --- /dev/null +++ b/templates/docker/java/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:17 +COPY ./ ./ +RUN javac Solution.java +CMD ["java", "Solution"] diff --git a/templates/solution/java/Solution.java b/templates/solution/java/Solution.java new file mode 100644 index 0000000..bede282 --- /dev/null +++ b/templates/solution/java/Solution.java @@ -0,0 +1,12 @@ +import java.util.Scanner; + +public class Solution { + public static void main(String[] args) { + String line; + Scanner scanner = new Scanner(System.in); + while(scanner.hasNextLine()) { + line = scanner.nextLine(); + System.out.println("Hello, " + line + "!"); + } + } +}