1
0

Finish Java Kompendium book

This commit is contained in:
2025-12-07 12:22:07 +01:00
parent 5eded28b16
commit c95abc31d6
30 changed files with 1400 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
public class GenericClass<T> {
public T value;
public GenericClass(T value) {
this.value = value;
}
}

View File

@@ -0,0 +1,9 @@
public class Main {
public static void main(String[] arguments) {
var i = new GenericClass<Integer>(2);
var l = new GenericClass<Long>(1l);
System.out.println(i.value);
System.out.println(l.value);
}
}

View File

@@ -0,0 +1,16 @@
import java.util.List;
public class Task1 {
private <T> void f(List<T> list) {
if (list.size() > 1) {
var swap = list.get(0);
var lastIndex = list.size() - 1;
list.set(0, list.get(lastIndex));
list.set(lastIndex, swap);
}
}
public static void main(String[] arguments) {
}
}