Hallo Leute,
habe folgendes Problem und zwar geht es um einen Quellcode den ich garnicht verstehe. Bzw. ich verstehe nicht wie es zu diesem Ergebniss beim Compilieren kommt.
Hiermal der Quellcode
Also was macht das Programm eigenlicht ?
PS : Ergebnisse als Kommentar im Quellcode
Ich bedanke mich schnonmal für die antworten. Danke
habe folgendes Problem und zwar geht es um einen Quellcode den ich garnicht verstehe. Bzw. ich verstehe nicht wie es zu diesem Ergebniss beim Compilieren kommt.
Hiermal der Quellcode
Java:
public class Ueberladen {
public static int foo(short x, int y){ return 1;}
public static int foo(long x, char y){ return 2;}
public static int foo(int x, int y){ return 3;}
public static int foo(char x, double y){ return 4;}
public static int foo(double x, int y){ return 5;}
public static int foo(int... x ){ return 6;}
public static int foo(short x ){ return 7;}
public static int foo(long x ){ return 8;}
public static void main(String[] args){
long x1 = (long) 1;
short x2 = (short) 2;
float x3 = (float) 3;
System.out.println(foo(1.0, x2)); // = 5
System.out.println(foo('x', x3)); // = 4
System.out.println(foo(x2, x2));// =1
System.out.println(foo(x2, 1));// = 1
System.out.println(foo(x1, 1));// = 5
System.out.println(foo(x1 ));// = 8
System.out.println(foo((byte)x2));// = 7
System.out.println(foo(1 ));// = 8
}
}
Also was macht das Programm eigenlicht ?
PS : Ergebnisse als Kommentar im Quellcode
Ich bedanke mich schnonmal für die antworten. Danke