Facebook
From Method OverLoading, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 77
  1.  
  2. public class Main
  3. {
  4.         public static void main(String[] args) {
  5.            
  6.             A a = new A();
  7.             a.display(3);
  8.             a.display(2,4);
  9.         // same  name method but different perpose of work         
  10.            
  11.         }
  12. }
  13.  
  14. class A{
  15.     int num = 4;
  16.     void display(int a){
  17.         System.out.println("Arguments: " + a);
  18.     }
  19.  
  20.     void display(int a, int b){
  21.         System.out.println("Arguments: " + a + " and " + b);
  22.     }
  23.    
  24. }
  25.