📄 example47
字号:
class MethodOverloading{
void receive( int i ){
System.out.println("Receive one int data ");
System.out.println("i = "+i);
}
void receive( int x, int y ){
System.out.println("Receive two int datas ");
System.out.println("x = "+x+" y = "+y);
}
void receive( double d ){
System.out.println("Receive one double data ");
System.out.println("d = "+d);
}
void receive( String s ){
System.out.println("Receive a string ");
System.out.println("s = "+s);
}
}
public class MethodOverloadingTest{
public static void main( String args[ ] ){
MethodOverloading mo = new MethodOverloading( );
mo.receive( 1 );
mo.receive( 2, 3 );
mo.receive( 12.56 );
mo.receive( "very interesting, isn't it?" );
}
}
运行结果为:
C:\>java MethodOverloadingTest
Receive one int data
i = 1
Receive two int datas
x = 2 y = 3
Receive one double data
d = 12.56
Receive a string
s = very interesting, isn't it?
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -