Glossary
Calling a Method
The act of executing a method by using its name and providing actual values (arguments) for its parameters.
Example:
To use a method that calculates the sum, you would perform calling a method like myCalculator.add(5, 10);.
Method
A block of code that performs a specific task. It can take inputs (parameters), follow a set of instructions, and produce an output.
Example:
In a game, a movePlayer method might take a direction as input and update the player's position on the screen.
Method Code
The set of instructions or statements contained within a method that define the specific task it performs. It's the 'recipe' a method follows.
Example:
Inside a calculateTax method, the method code would include calculations like tax = income * taxRate;.
Method Signature
The unique identifier of a method, consisting of its name and the ordered list of its parameter types. It defines how the method can be called.
Example:
The method signature for public static void calculateSum(int num1, int num2) is calculateSum(int, int).
Output (of a method)
The result produced by a method after it executes its instructions. This can be a returned value, a printed message, or a change in data.
Example:
A method calculateHypotenuse(double a, double b) would return a double value as its output.
Overloading Methods
The ability to define multiple methods within the same class that share the same name but have different parameter lists (different types, number, or order of parameters).
Example:
You could have a printShape method that takes a double radius for a circle, and another printShape method that takes double length, double width for a rectangle, demonstrating overloading methods.
Parameters
Values passed into a method as inputs, allowing the method to perform its task with specific data. They are like the ingredients you give to a recipe.
Example:
A calculateArea method might take length and width as its parameters to compute the area of a rectangle.
Void Method
A method that performs a task but does not return any value. Its purpose is often to produce a side effect, such as printing to the console or modifying an object's state.
Example:
A printGreeting method that takes a name and simply prints 'Hello, name!' to the console is a void method.