: The variables defined in the method signature.
: The unique name used to call the method (usually camelCase). : The variables defined in the method signature
public static void greetUser(String name) { // "name" is a parameter System.out.println("Hello, " + name); } public static void main(String[] args) { greetUser("Ahmed"); // "Ahmed" is an argument } Use code with caution. Copied to clipboard 5. The return Keyword Copied to clipboard 5
If a method has a return type other than void , it use the return statement to send a value back to the caller. sum(int a, int b) sum(double a, double b)
In Java, multiple methods can have the as long as they have different parameters (different types or different number of parameters). sum(int a, int b) sum(double a, double b) sum(int a, int b, int c) 7. Scope of Variables
A method is a collection of statements grouped together to perform an operation.
: The data type the method returns (e.g., int , String ). Use void if it returns nothing.