class Demo{
void test(){
System.out.println("No parameter");
}
void test(int a, int b){
System.out.println("a and b is: " + a +" "+b);
}
void test(double a){
System.out.println("a is: " + a);
}
}
public class Main{
public static void main(String args[]){
Demo dm = new Demo();
dm.test();
dm.test(7,5);
dm.test(3.5);
dm.test(4); //type conversion happened here
}
}
Automatic type conversion in method overloading
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment