一.
import java.util.Random; public class inta { public static void main(String args[]) { Random r = new Random(System.currentTimeMillis()); for(int i=1;i<1000;i++) { int m=r.nextInt(); m=(16807*m+0)%2147483647; System.out.print(m+" "); if(i%10==0) System.out.print(" "); } } }
public class MethodOverload { public static void main(String[] args) { System.out.println("The square of integer 7 is " + square(7)); System.out.println(" The square of double 7.5 is " + square(7.5)); } public static int square(int x)//int类型 { return x * x; } public static double square(double y)//double类型 { return y * y; } }
使用了java 的方法重载,(1)方法名相同;
(2)参数类型不同,参数个数不同,或者是参数类型的顺序不同
二.怎么才可以用传参的值把主函数的改变