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
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;
}
}
运行结果:
运行结果分析:
可变参数和重载的参数相关联。