program using method and method overloading in java
Method describe behavior of an object. A method is a collection of statements that are group together to perform an operation.
There are three step to
define Method:
1) Declaration--> return_type
method_name()
2) Define --> {
}
3) Call --> call with object
Syntax:
return_type method_name(){
// body of method
}
Declaration of method:
void java_pivot(){
//body of method
System.out.println(“ I am java pivot method”);
}
//program to add two no. using method
public class Methodadd {
void add(int a,int b){
int c= a+b;
System.out.println(c);
}
public static void main(String[] args) {
Methodadd ad = new Methodadd();
ad.add(10, 12);
}
}
Output:
0 comments: