Java examples for Object Oriented Design:Method Overloading
Function signatures do not take into account the return type
public class Main { static double plusone(int n) { return n + 1.0; }// w w w.j a va2 s.c om static double plusone(double x) { return x + 1.0; } static double plusone(String s) { return Double.parseDouble(s) + 1.0; } public static void main(String[] args) { System.out.println(plusone(15)); System.out.println(plusone(6.23)); System.out.println(plusone("123.2")); } }