feat: Ermögliche die Addition mehrerer Ganzzahlen

featureAddition
hummel 2024-06-14 12:04:52 +02:00
parent 423283c511
commit e94a5c5242
1 changed files with 16 additions and 1 deletions

View File

@ -4,6 +4,21 @@ public class Main {
public static void main(String[] args) {
System.out.println("Hallo Welt!");
Main m = new Main();
System.out.println();
System.out.printf("Die Summe von %d + % d = %d", 3, 8, m.add(3, 8));
System.out.printf("Es geht noch besser: %d + %d + %d = %d", 2, 5, 9, m.add(2, 5, 9));
}
public int add(int... numbers) {
int res = 0;
for (int n : numbers)
res += n;
return res;
}
}
}