@toudidel/Przeciążanie funkcji
Java

No description

Files
  • Main.java
Main.java
public class Main {

    public static void main(String[] args) {

        Integer suma = dodaj(1, 2, 3, 4, 5, 6);
        System.out.println(suma);
    }

    public static Integer dodaj(Integer... tab) {
        Integer suma = 0;
        
        for (int i = 0; i < tab.length; i++) {
          suma += tab[i];
        }
        
        return suma;
    }
}
java version "1.8.0_31" Java(TM) SE Runtime Environment (build 1.8.0_31-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)