The functions are called as methods in java. And methods are helps to access the instance-variables and provide functionality on the data as required. And the methods can be declared in a class.
Declaration of methods:
Syntax:
return-type method-name(parameter-list)
{
Body of the method
————————
————————
}
First we have the return type that means what we want to return from method.
Then we have method name.
Then a parameter-list, it can be more than one and may be different in data type.
Then we have body of method all the operations are performed in this body.
e.g:
void add(int a,int b)
{
c = a+b;
return(c);
}