In this example we will show how to overload method in Java.
Source Code
package com.beginner.examples;
public class OverloadMethod {
static int test(int a) { // int
return a;
}
static double test(double a) { // double
return a;
}
public static void main(String[] args) {
int i = test(82);
double d = test(7.9);
System.out.println("Int: " + i);
System.out.println("Double: " + d);
}
}
Output:
Int: 82
Double: 7.9