diff --git a/DatenspeicherMinMax/.vscode/settings.json b/DatenspeicherMinMax/.vscode/settings.json new file mode 100644 index 0000000..0ac215c --- /dev/null +++ b/DatenspeicherMinMax/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/DatenspeicherMinMax/README.md b/DatenspeicherMinMax/README.md new file mode 100644 index 0000000..a43b9f6 --- /dev/null +++ b/DatenspeicherMinMax/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/DatenspeicherMinMax/src/DatenspeicherMinMax.java b/DatenspeicherMinMax/src/DatenspeicherMinMax.java new file mode 100644 index 0000000..5a9f985 --- /dev/null +++ b/DatenspeicherMinMax/src/DatenspeicherMinMax.java @@ -0,0 +1,21 @@ +public class DatenspeicherMinMax { + private T min, max; + + public void setMax(T neuerWert) { + if (neuerWert > max) + max = neuerWert; + } + + public void setMin(T neuerWert) { + if (neuerWert < min) + min = neuerWert; + } + + public T getMax() { + return max; + } + + public T getMin() { + return min; + } +} diff --git a/DatenspeicherMinMax/src/Test.java b/DatenspeicherMinMax/src/Test.java new file mode 100644 index 0000000..c15eec7 --- /dev/null +++ b/DatenspeicherMinMax/src/Test.java @@ -0,0 +1,8 @@ +public class Test { + public static void main(String[] args) throws Exception { + DatenspeicherMinMax dF = + new DatenspeicherMinMax<>(); + + dF.setMin(3.75f); // Geht das??? + } +} diff --git a/DatenspeicherMinMax2/.vscode/settings.json b/DatenspeicherMinMax2/.vscode/settings.json new file mode 100644 index 0000000..0ac215c --- /dev/null +++ b/DatenspeicherMinMax2/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/DatenspeicherMinMax2/README.md b/DatenspeicherMinMax2/README.md new file mode 100644 index 0000000..a43b9f6 --- /dev/null +++ b/DatenspeicherMinMax2/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/DatenspeicherMinMax2/src/DatenspeicherMinMax2.java b/DatenspeicherMinMax2/src/DatenspeicherMinMax2.java new file mode 100644 index 0000000..8fa3080 --- /dev/null +++ b/DatenspeicherMinMax2/src/DatenspeicherMinMax2.java @@ -0,0 +1,20 @@ +public class DatenspeicherMinMax2> { + private T min, max; + + public void pruefeMax(T neuerWert) + { + if(neuerWert.compareTo(max) > 0) + max = neuerWert; + } + + public void pruefeMin(T neuerWert) + { + if(neuerWert.compareTo(min) < 0) + min = neuerWert; + } + + public void setMax(T neuerWert) { max = neuerWert; } + public void setMin(T neuerWert) { min = neuerWert; } + public T getMax() { return max; } + public T getMin() { return min; } +} diff --git a/DatenspeicherMinMax2/src/Test.java b/DatenspeicherMinMax2/src/Test.java new file mode 100644 index 0000000..719668f --- /dev/null +++ b/DatenspeicherMinMax2/src/Test.java @@ -0,0 +1,8 @@ +public class Test { + public static void main(String[] args) throws Exception { + DatenspeicherMinMax2 dF = + new DatenspeicherMinMax2<>(); + + dF.setMin(3.75f); // Geht das??? + } +} diff --git a/DatenspeicherPaar/.vscode/settings.json b/DatenspeicherPaar/.vscode/settings.json new file mode 100644 index 0000000..0ac215c --- /dev/null +++ b/DatenspeicherPaar/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/DatenspeicherPaar/README.md b/DatenspeicherPaar/README.md new file mode 100644 index 0000000..a43b9f6 --- /dev/null +++ b/DatenspeicherPaar/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/DatenspeicherPaar/src/DatenspeicherPaar.java b/DatenspeicherPaar/src/DatenspeicherPaar.java new file mode 100644 index 0000000..049d6f1 --- /dev/null +++ b/DatenspeicherPaar/src/DatenspeicherPaar.java @@ -0,0 +1,18 @@ + +public class DatenspeicherPaar { + private T1 wert1; + private T2 wert2; + + public void setPaar(T1 nW1, T2 nW2) { + wert1 = nW1; + wert2 = nW2; + } + + public T1 getWert1() { + return wert1; + } + + public T2 getWert2() { + return wert2; + } +} diff --git a/DatenspeicherPaar/src/TestPaar.java b/DatenspeicherPaar/src/TestPaar.java new file mode 100644 index 0000000..bd8af56 --- /dev/null +++ b/DatenspeicherPaar/src/TestPaar.java @@ -0,0 +1,9 @@ +public class TestPaar { + public static void main(String[] args) throws Exception { + DatenspeicherPaar dsP = new DatenspeicherPaar<>(); + + dsP.setPaar("Java-Version", 19); + + System.out.println(dsP.getWert1() + " " + dsP.getWert2()); + } +} diff --git a/Dreieckstausch/.vscode/settings.json b/Dreieckstausch/.vscode/settings.json new file mode 100644 index 0000000..0ac215c --- /dev/null +++ b/Dreieckstausch/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Dreieckstausch/README.md b/Dreieckstausch/README.md new file mode 100644 index 0000000..a43b9f6 --- /dev/null +++ b/Dreieckstausch/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/Dreieckstausch/src/Dreieckstausch.java b/Dreieckstausch/src/Dreieckstausch.java new file mode 100644 index 0000000..5701576 --- /dev/null +++ b/Dreieckstausch/src/Dreieckstausch.java @@ -0,0 +1,17 @@ +public class Dreieckstausch { + public static void tausche(E [] f) + { + E s = f[0]; f[0] = f[1]; f[1] = s; + } + + public static void main(String args []) + { + Double v[] = {1.0, 2.0}; + + System.out.println(v[0] + " " + v[1]); + + Dreieckstausch.tausche(v); + + System.out.println(v[0] + " " + v[1]); + } +} diff --git a/EigeneException/.vscode/settings.json b/EigeneException/.vscode/settings.json new file mode 100644 index 0000000..0ac215c --- /dev/null +++ b/EigeneException/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/EigeneException/README.md b/EigeneException/README.md new file mode 100644 index 0000000..a43b9f6 --- /dev/null +++ b/EigeneException/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/EigeneException/src/EigeneException.java b/EigeneException/src/EigeneException.java new file mode 100644 index 0000000..3f01205 --- /dev/null +++ b/EigeneException/src/EigeneException.java @@ -0,0 +1,18 @@ +public class EigeneException { + public static double division(double zaehler, double nenner) throws NullDivisionException { + if(nenner == 0.0) + throw new NullDivisionException("Nulldivision", zaehler); + else + return zaehler / nenner; + } + public static void main(String [] args) { + try { + double zaehler = 21.3; + double nenner = 0.0; + double bruch = division(zaehler, nenner); + System.out.printf("\n\t %f : %f = %f\n", zaehler, nenner, bruch); + } catch (NullDivisionException e) { + System.err.println(e.getMessage() + " mit Zaehler: " + e.getZaehler()); + } + } +} \ No newline at end of file diff --git a/EigeneException/src/NullDevisionException.java b/EigeneException/src/NullDevisionException.java new file mode 100644 index 0000000..c8faab0 --- /dev/null +++ b/EigeneException/src/NullDevisionException.java @@ -0,0 +1,14 @@ +class NullDivisionException extends Exception { + private double zaehler; + + public NullDivisionException() { } + public NullDivisionException(String meldung) { + super(meldung); + } + public NullDivisionException(String meldung, double zaehler) { + super(meldung); + this.zaehler = zaehler; + } + + public double getZaehler() { return zaehler; } +} diff --git a/Geburtstagsverzeichnis/.vscode/settings.json b/Geburtstagsverzeichnis/.vscode/settings.json new file mode 100644 index 0000000..0ac215c --- /dev/null +++ b/Geburtstagsverzeichnis/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Geburtstagsverzeichnis/README.md b/Geburtstagsverzeichnis/README.md new file mode 100644 index 0000000..a43b9f6 --- /dev/null +++ b/Geburtstagsverzeichnis/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/Geburtstagsverzeichnis/src/Geburtstagsverzeichnis.java b/Geburtstagsverzeichnis/src/Geburtstagsverzeichnis.java new file mode 100644 index 0000000..ee8abec --- /dev/null +++ b/Geburtstagsverzeichnis/src/Geburtstagsverzeichnis.java @@ -0,0 +1,18 @@ +import java.util.HashMap; +import java.util.Map; +import java.time.LocalDate; + +public class Geburtstagsverzeichnis { + public static void main(String[] args) { + Map gv = new HashMap<>(); + + gv.put("Klaus", + LocalDate.of(1994, 12, 23)); + gv.put("Erika", + LocalDate.of(1992, 5, 3)); + + System.out.println("Klaus' Geburtstag: " + + gv.get("Klaus").toString()); + } +} + diff --git a/Maximum/.vscode/settings.json b/Maximum/.vscode/settings.json new file mode 100644 index 0000000..0ac215c --- /dev/null +++ b/Maximum/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Maximum/README.md b/Maximum/README.md new file mode 100644 index 0000000..a43b9f6 --- /dev/null +++ b/Maximum/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/Maximum/src/Maximum.java b/Maximum/src/Maximum.java new file mode 100644 index 0000000..644af30 --- /dev/null +++ b/Maximum/src/Maximum.java @@ -0,0 +1,15 @@ +public class Maximum { + public static + > + T max(T w1, T w2) { + if(w1.compareTo(w2) > 0) + return w1; + else + return w2; + } + + public static void main(String args []) { + System.out.println("Max: " + + max(1.0, 2.0)); + } +} \ No newline at end of file diff --git a/Seiteneffekt/.vscode/settings.json b/Seiteneffekt/.vscode/settings.json new file mode 100644 index 0000000..0ac215c --- /dev/null +++ b/Seiteneffekt/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/Seiteneffekt/README.md b/Seiteneffekt/README.md new file mode 100644 index 0000000..a43b9f6 --- /dev/null +++ b/Seiteneffekt/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/Seiteneffekt/src/Door.java b/Seiteneffekt/src/Door.java new file mode 100644 index 0000000..6f36155 --- /dev/null +++ b/Seiteneffekt/src/Door.java @@ -0,0 +1,16 @@ +class SwingException extends Exception {} +class CloseException extends Exception {} + +class Door implements AutoCloseable { + + public void swing() throws Exception { + System.out.println("The door is becoming unhinged!"); + close(); + throw new SwingException(); + } + + public void close() throws Exception { + System.out.println("The door is now closed."); + throw new CloseException(); + } +} diff --git a/Seiteneffekt/src/SuppressedExceptionExample.java b/Seiteneffekt/src/SuppressedExceptionExample.java new file mode 100644 index 0000000..d2c80ef --- /dev/null +++ b/Seiteneffekt/src/SuppressedExceptionExample.java @@ -0,0 +1,13 @@ +public class SuppressedExceptionExample { + public static void main(String[] args) throws Exception { + + try (Door door = new Door()) { + door.swing(); /* Throws the SwingException */ + } catch (Exception e) { + System.out.println("Primary Exception: " + e.getClass()); + if (e.getSuppressed().length > 0) { + System.out.print("Suppressed Exception: " + e.getSuppressed()[0]); + } + } + } +} diff --git a/VerketteExceptions/.vscode/settings.json b/VerketteExceptions/.vscode/settings.json new file mode 100644 index 0000000..0ac215c --- /dev/null +++ b/VerketteExceptions/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/VerketteExceptions/README.md b/VerketteExceptions/README.md new file mode 100644 index 0000000..a43b9f6 --- /dev/null +++ b/VerketteExceptions/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/VerketteExceptions/src/VerketteteExceptions.java b/VerketteExceptions/src/VerketteteExceptions.java new file mode 100644 index 0000000..ff27b62 --- /dev/null +++ b/VerketteExceptions/src/VerketteteExceptions.java @@ -0,0 +1,19 @@ +public class VerketteteExceptions { + public static void eineMethode() { + try { + throw new Exception("Originale Exception"); + } + catch(Exception ex) { + throw new RuntimeException(ex); // Exception verketten + } + } + + public static void main(String [] args) { + + try { + eineMethode(); + } catch(Exception ex) { + System.console().printf(" %s\n", ex.getCause().toString()); + } + } +}