+ 1
Java code question. Method inside method.
Hello everybody. The question is Why "max (c,d)" works without particular method description? https://code.sololearn.com/cat2XIrA2RZa/?ref=app
3 odpowiedzi
+ 2
max(c,d) is calling this function
public static int max(int a, int b) {
if (a > b) return a;
else return b;
}
That's why it works ,c and d are arguments passed to a and b parameters ,a and b doesn't means that it will only accept arguments with variable name a and b
+ 2
You have all descriptions..
Where you mean " without perticular description?" in code?
You have method for max with 2 arguments, and overloaded 4 argument method...
max(c, d) calls 2 argument max method..
From 4 argument max method, first you are calling 2 argument max method 2 times, and you get 2 return values by that values, you are again calling one more time, and in return you get final result..
+ 1
Thanks. Now I understand this.