可变参数

10.02

可变参数代码部分:

package lianxi;
import java.util.*;
import javax.swing.*;
public class bo {
public static void main(String[] args) {

System.out.println("The square of integer 7 is " + square(7));
System.out.println("\nThe square of double 7.5 is " + square(7.5));
}

public static int square(int x)
{
return x * x;
}

public static double square(double y)
{
return y * y;
}
}

运行结果:

 

 运行结果分析:

可变参数和重载的参数相关联。

posted @ 2020-10-02 10:26  潘福龙  阅读(27)  评论(0编辑  收藏  举报