Add Java-Kompendium book
This commit is contained in:
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user