Doç. Dr. GÜRAY SONUGÜR

Doç. Dr. Güray SONUGÜR – Öğrenci Bilgi Paylaşım Platformu

Overloading -1

 

public class overloading_ders1 {
public static void main(String[] args) {
int sayilar[]= new int[]{3,22,34,45};
System.out.println(topla(2,7));
System.out.println(topla(2,7,9));
System.out.println(topla(sayilar));

}

private static int topla(int sayi1, int sayi2)
{
return sayi1+sayi2;
}
private static int topla(int sayi1, int sayi2, int sayi3)
{
return sayi1+sayi2+sayi3;
}

private static int topla(int[] sayilar)
{
int tmp=0;
for (int s : sayilar) {
tmp +=s;
}
return tmp;

}

}