Подписи методов
Введено| English | Значение |
|---|---|
| method/ˈmeθəd/ | метод |
| signature/ˈsɪɡnɪtʃə/ | подпись метода |
| parameter/pəˈræmɪtə/ | формальный параметр |
| argument/ˈɑːɡjuːmənt/ | фактический аргумент |
| overloading/ˌəʊvəˈləʊdɪŋ/ | переопределение (перезагрузка) |
A method's name tag
- A method 方法 is a named block of code you can call to do a job.
- Its signature 方法签名 is the part that identifies it: the name plus the parameter list.
- Example signature:
max(int a, int b)— namemax, twointparameters. - The signature is how Java knows which method you mean when you call one.
Parameters and arguments
- A parameter 形参 is a variable in the method's definition:
int ainmax(int a, int b). - An argument 实参 is the actual value you pass when calling:
max(5, 9)passes5and9. - Arguments are matched to parameters by position, left to right.
- Inside the method, the parameters hold copies of the arguments.

The parts of a method signature and a call that matches it
The return type
- A method's return type says what kind of value it hands back.
public int max(int a, int b)returns anint; avoidmethod returns nothing.- Use
return value;to send a result back to the caller. - The return type is part of the header but not part of the signature.
Overloading: same name, different signature
- Java allows overloading 重载: several methods with the same name but different parameter lists.
print(int x)andprint(String s)are distinct — the argument types tell them apart.- The compiler picks the version whose signature matches your arguments.
- Overloading only works when the signatures differ (return type alone is not enough).
The signature is name + parameter list — the return type is NOT part of it. That's why you can't overload two methods that differ only by return type. Parameters live in the definition; arguments are the values you pass, matched by position. Passing the wrong number or type of arguments is a compile error.
Calling max:
- Definition:
public int max(int a, int b) { return a > b ? a : b; } - Call:
int m = max(5, 9);→ argument5→ parametera,9→b. - The method returns
9, stored inm.
A method signature is its name plus parameter list (the return type is not part of it). Parameters are the definition's variables; arguments are the values passed at a call, matched by position. Overloading allows the same name with different parameter lists, distinguished by the arguments.
Вызов метода возвращает значение
Аргументы 5 и 9 привязываются к параметрам a и b; метод возвращает 9.
Подпись метода состоит из его...
Сложность 1/5 · 100 монет + небольшой бонус за первое выполнение сегодня
Подпись = имя + параметры; тип возврата не является её частью.
В вызове max(5, 9) значения 5 и 9 являются...
Сложность 1/5 · 100 монет + небольшой бонус за первое выполнение сегодня
Аргументы — это передаваемые значения; параметры существуют в определении.
Вы можете перегрузить два метода, отличающихся только типом возврата.
Сложность 1/5 · 100 монет + небольшой бонус за первое выполнение сегодня
Тип возврата не входит в подпись, поэтому это запрещено.
Наличие нескольких методов с одинаковым именем, но разными списками параметров, называется...
Сложность 1/5 · 100 монет + небольшой бонус за первое выполнение сегодня
Перегрузка = одинаковое имя, разные списки параметров.
Аргументы сопоставляются с параметрами по их ___ (одно слово), слева направо.
Сложность 1/5 · 100 монет + небольшой бонус за первое выполнение сегодня
Позиционное сопоставление: первый аргумент → первый параметр.