举例如下
public class Test
{
public static void main(String[] args)
{
int isum;
double dsum;
isum = add(3,5);
System.out.println("第一个isum="+isum);
isum = add(3,4,5);
System.out.println("第二个isum="+isum);
dsum = add(2.3,3.5);
System.out.println("第三个isum="+dsum);
}public static int add(int x,int y)
{
return x+y;
}
public static int add(int x,int y,int z)
{
return x+y+z;
}
public static double add(double x,double y)
{
return x+y;
}
}这样的例子还有很多,编程不要死记硬背,要变通,触类旁通