Files
pharo-mooc/Java-Kompendium/kap6/Task1.java

38 lines
1.0 KiB
Java

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));
}
}