Card 10/ 10
Recap: Methods and Pass-by-Value
Signatures, parameters, pass-by-value and overloading, with where each was.
Methods come down to the five ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
| A signature has five parts, and only the parameter list decides which method a call matches | Method Signature Example: Reading public static int add |
| A parameter is a name in the declaration; an argument is a value at the call | Parameters vs Arguments |
| Java passes everything by value, and a reference is a value | Pass-by-Value in Java, Including References |
| Mutating through the reference reaches the caller; reassigning the parameter does not | Pass-by-Value Example: A Method That Reassigns Its Parameter |
| Overloading resolves on the parameter list, never on the return type | Method Overloading: What the Compiler Matches On |
A method can change the object you gave it and can never change the variable you gave it. Anything a method needs to hand back, it hands back by returning it.
← → move through sections and cards