Java Method Nesting and Overloading

In this tutorial, you will learn about java Method nesting and overloading.

You will learn what is method nesting and method overloading, how to do that, what is the advantage, how do they work in detail with example.

Source code for this video tutorial

Code for Test.java

package oops;

public class Test {
 
 int max(int num1,int num2){
  System.out.println("for integer data with 2 prameters");
  if( num1 > num2 ){
   return num1;
  }else{
   return num2;
  }
 }
 
 int max(int num1,int num2,int num3){
  System.out.println("for integer data with 3 parameters");
  int result = max(num1,num2);
  return max(result,num3);
 }
 
 
 double max(double num1,double num2){
  System.out.println("for doubler data");
  if( num1 > num2 ){
   return num1;
  }else{
   return num2;
  }
 }
}

Code for Tutorial.java

package oops;

public class Tutorial {

 public static void main(String[] args) {
  
  Test t = new Test();
  
  System.out.println("The maximum is "+t.max(22,33,55));

 }

}