When an application contains just one version of a method, you can call the method using a parameter of the correct data type or one that can be promoted to the correct data type. For example, you can call a method which needs double variable datatype use int value, but not allowed versa vice.
publicstaticvoid simpleMethod(double d){
System.out.println("Method receives double parameter "+d);
}
publicstaticvoid main(String[] args){
Test2.simpleMethod(1.00);
Test2.simpleMethod(1);
}
Output:
Method receives double parameter 1.0
Method receives double parameter 1.0
publicstaticvoid simpleMethod(double d){
System.out.println("Method receives double parameter "+d);
}
publicstaticvoid simpleMethod(int i){
System.out.println("Method receives int parameter "+i);
}
publicstaticvoid main(String[] args){
Test2.simpleMethod(1.00);
Test2.simpleMethod(1);
}
Output:
Method receives double parameter 1.0
Method receives int parameter 1