From a680b83e47a283106dee9557c5c9ee5dc175551e Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 24 Nov 2025 23:20:51 +0100 Subject: [PATCH] Add Java-Kompendium book --- Java-Kompendium/.gitignore | 1 + Java-Kompendium/kap3/HalloWelt.java | 11 +++++++++ Java-Kompendium/kap5/Task1.java | 10 ++++++++ Java-Kompendium/kap5/Task2.java | 15 ++++++++++++ Java-Kompendium/kap6/Task1.java | 37 +++++++++++++++++++++++++++++ Java-Kompendium/kap6/Task2.java | 15 ++++++++++++ Java-Kompendium/kap6/Task3.java | 29 ++++++++++++++++++++++ README.md | 4 ++++ 8 files changed, 122 insertions(+) create mode 100644 Java-Kompendium/.gitignore create mode 100644 Java-Kompendium/kap3/HalloWelt.java create mode 100644 Java-Kompendium/kap5/Task1.java create mode 100644 Java-Kompendium/kap5/Task2.java create mode 100644 Java-Kompendium/kap6/Task1.java create mode 100644 Java-Kompendium/kap6/Task2.java create mode 100644 Java-Kompendium/kap6/Task3.java diff --git a/Java-Kompendium/.gitignore b/Java-Kompendium/.gitignore new file mode 100644 index 0000000..6b468b6 --- /dev/null +++ b/Java-Kompendium/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/Java-Kompendium/kap3/HalloWelt.java b/Java-Kompendium/kap3/HalloWelt.java new file mode 100644 index 0000000..78817de --- /dev/null +++ b/Java-Kompendium/kap3/HalloWelt.java @@ -0,0 +1,11 @@ +// OOP sucks. +public class HalloWelt { + /** + * Java sucks. + * + * @param args Command line arguments. + */ + public static void main(String[] args) { + System.out.print("Java sucks\n"); + } +} diff --git a/Java-Kompendium/kap5/Task1.java b/Java-Kompendium/kap5/Task1.java new file mode 100644 index 0000000..1ec010c --- /dev/null +++ b/Java-Kompendium/kap5/Task1.java @@ -0,0 +1,10 @@ +public class Task1 { + public static void main(String[] args) { + int x; + short y = 8; + long z; + + x = y; + z = y; + } +} diff --git a/Java-Kompendium/kap5/Task2.java b/Java-Kompendium/kap5/Task2.java new file mode 100644 index 0000000..751364a --- /dev/null +++ b/Java-Kompendium/kap5/Task2.java @@ -0,0 +1,15 @@ +import java.io.*; + +public class Task2 { + public static void main(String[] args) throws IOException { + System.out.print("Geben Sie eine Zahl ein: "); + + var inputStream = new InputStreamReader(System.in); + var bufferedStream = new BufferedReader(inputStream); + + String variable = bufferedStream.readLine(); + int converted = Integer.parseInt(variable); + + System.out.println("Der doppelte Wert ist: " + (converted * 2)); + } +} diff --git a/Java-Kompendium/kap6/Task1.java b/Java-Kompendium/kap6/Task1.java new file mode 100644 index 0000000..9861d6f --- /dev/null +++ b/Java-Kompendium/kap6/Task1.java @@ -0,0 +1,37 @@ +import java.util.*; + +public class Task1 { + public static void main(String[] args) { + ArrayList workers = new ArrayList<>(6); + + workers.add("Maximilian Mayer"); + workers.add("Emil Faber"); + workers.add("Anna Müller"); + workers.add("Sebastian Waller"); + workers.add("Oliver Stilz"); + workers.add("Peter Huber"); + + print(workers); + System.out.println(); + + System.out.print("Der erste Name: "); + System.out.println(workers.get(0)); + + System.out.print("Der letzte Name: "); + System.out.println(workers.get(workers.size() - 1)); + + workers.set(3, "Frank Starke"); + + System.out.println(); + print(workers); + } + + public static void print(ArrayList list) { + System.out.println(list.get(0)); + System.out.println(list.get(1)); + System.out.println(list.get(2)); + System.out.println(list.get(3)); + System.out.println(list.get(4)); + System.out.println(list.get(5)); + } +} diff --git a/Java-Kompendium/kap6/Task2.java b/Java-Kompendium/kap6/Task2.java new file mode 100644 index 0000000..bbec0a0 --- /dev/null +++ b/Java-Kompendium/kap6/Task2.java @@ -0,0 +1,15 @@ +import java.util.*; +import java.io.*; + +public class Task2 { + public static void main(String[] args) throws IOException { + var workers = new ArrayList(); + var stream = new InputStreamReader(System.in); + var bufferedStream = new BufferedReader(stream); + + for (int i = 0; i < 5; ++i) { + workers.add(bufferedStream.readLine()); + } + System.out.println("Folgende Mitarbeiter haben sie angegeben: " + workers); + } +} diff --git a/Java-Kompendium/kap6/Task3.java b/Java-Kompendium/kap6/Task3.java new file mode 100644 index 0000000..88266fd --- /dev/null +++ b/Java-Kompendium/kap6/Task3.java @@ -0,0 +1,29 @@ +import java.util.*; + +public class Task3 { + public static void main(String[] args) { + var javaList = new HashSet(3); + var pythonList = new HashSet(3); + var commonList = new HashSet(); + var differenceSet = new HashSet(); + + javaList.add("Maximilian Mayer"); + javaList.add("Emil Faber"); + javaList.add("Anna Müller"); + + pythonList.add("Anna Müller"); + pythonList.add("Sebastian Waller"); + pythonList.add("Oliver Stilz"); + + commonList.addAll(javaList); + commonList.addAll(pythonList); + + differenceSet.addAll(javaList); + differenceSet.retainAll(pythonList); + + System.out.println("Java-Kurs: " + javaList); + System.out.println("Python-Kurs: " + pythonList); + System.out.println("Alle Teilnehmer: " + commonList); + System.out.println("Beide Kurse: " + differenceSet); + } +} diff --git a/README.md b/README.md index 2182d5a..90c4aa1 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,7 @@ This repository contains some excercises and projects from "[The Pharo Mooc](https://mooc.pharo.org/)". + +## Java-Kompendium. Professionell Java programmieren lernen + +Von Markus Neumann.