• Source
    1. /*
    2.  
    3.  
    4. Date : 11 November 2013
    5. Author : Shivam Tiwari
    6. Organization : http://mycodedock.blogspot.in/
    7. Description : Demonstrating function over-loading in Java
    8.  
    9.  
    10. */
    11.  
    12. //main class
    13. public class Main{
    14.  
    15. //defining first function
    16. static int myFunc(int x, int y, int z){
    17. return ((x*y) + z);
    18. }
    19.  
    20. //defining second function (with same name)
    21. static double myFunc(double a, double b, double c){
    22. return ((a*b) + c);
    23. }
    24.  
    25. //main function
    26. public static void main(String[] args){
    27.  
    28.  
    29. //now lets check it by printing
    30. int num = myFunc(2,3,4);
    31. System.out.println(num);
    32.  
    33. double num2 = myFunc(2.3,4.5,6.7);
    34. System.out.println(num2);
    35. }
    36. }