Day 3 Methods in Java
Day 3 Methods in Java
Day 3
class Month
int month;
int year Data declarations
Method declarations
• Header
qualifiers properties return-type
method-name ( formal-parameters )
throws-clause
• Body
{
Statements;
}
class MyClass
{ …
public static int min ( int num1, int num2 )
parameter list
The parameter list specifies the type
method
and name of each parameter
name
Qualifiers
return The name of a parameter in the method
type declaration is called a formal argument
properties
Java Training for WIPRO TalentNext
13-Mar-18 6
2017 -Vaibhav Diwan
Method Declaration: Body
The header is followed by the method body:
class MyClass
{
…
static int min(int num1, int num2)
{
int minValue = num1 < num2 ? num1 : num2;
return minValue;
}
…
}
min(1, 2, 3);
…println(…)
Invocation