一、随机数生成器:使用公式生成指定数量的随机数
import java.util.Scanner;public class random {
public static void main(String[] args) {
int n;
int a = 2147483647;
int c = 0;
int m = 16807;
Scanner ci = new Scanner(System.in);
n = ci.nextInt();
int x = n;
for(int i = 0; i < n; i++){
System.out.println(x);
x = (a*x+c)%m;
c++;
}
}
}
二、方法的重载:要求参数表不同
public class MethodOverload {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;
}
}
标签:square,22,int,System,static,public,23.9,out From: https://www.cnblogs.com/atrue/p/17723353.html