When we create interface methods, can't we do something like in java:
void interface_method(Integer,String, /* other parameter */);
Instead I noticed that we also need to give the parameter names lile:
void interface_method(Integer i, String s);
Also the interface implementor don't need to have the same parameter name as in interface method.
I found a similar question about c# over here . They mention one scenario of named parameter but I don't find any other relevent reason specifically in java.
This name is used in the statements in the procedure to refer to the value that will be passed as an actual parameter when the procedure is called. The mode of the formal parameter is in, indicating that it is used to pass information into the procedure from the caller.
The caller's arguments passed to the function's parameters do not have to have the same names.
Yes, you can pass Interface as a parameter in the function.
You can obtain the names of the formal parameters of any method or constructor with the method java. lang.
From a technical standpoint it wouldn't be necessary.
I've always taken it as a syntax normalization, and a documentation aid.
This way there's:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With