Add Java-Kompendium book
This commit is contained in:
1
Java-Kompendium/.gitignore
vendored
Normal file
1
Java-Kompendium/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.class
|
||||
11
Java-Kompendium/kap3/HalloWelt.java
Normal file
11
Java-Kompendium/kap3/HalloWelt.java
Normal file
@@ -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");
|
||||
}
|
||||
}
|
||||
10
Java-Kompendium/kap5/Task1.java
Normal file
10
Java-Kompendium/kap5/Task1.java
Normal file
@@ -0,0 +1,10 @@
|
||||
public class Task1 {
|
||||
public static void main(String[] args) {
|
||||
int x;
|
||||
short y = 8;
|
||||
long z;
|
||||
|
||||
x = y;
|
||||
z = y;
|
||||
}
|
||||
}
|
||||
15
Java-Kompendium/kap5/Task2.java
Normal file
15
Java-Kompendium/kap5/Task2.java
Normal file
@@ -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));
|
||||
}
|
||||
}
|
||||
37
Java-Kompendium/kap6/Task1.java
Normal file
37
Java-Kompendium/kap6/Task1.java
Normal file
@@ -0,0 +1,37 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Task1 {
|
||||
public static void main(String[] args) {
|
||||
ArrayList<String> 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<String> 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));
|
||||
}
|
||||
}
|
||||
15
Java-Kompendium/kap6/Task2.java
Normal file
15
Java-Kompendium/kap6/Task2.java
Normal file
@@ -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<String>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
29
Java-Kompendium/kap6/Task3.java
Normal file
29
Java-Kompendium/kap6/Task3.java
Normal file
@@ -0,0 +1,29 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Task3 {
|
||||
public static void main(String[] args) {
|
||||
var javaList = new HashSet<String>(3);
|
||||
var pythonList = new HashSet<String>(3);
|
||||
var commonList = new HashSet<String>();
|
||||
var differenceSet = new HashSet<String>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user