guozi6

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
package random;

import java.util.Random;

public class testseed1000 {

public static void main(String[] args){
Random ran =new Random(System.currentTimeMillis());
for(int i=0;i<1000;i++){
System.out.println(ran.nextInt());

}
}


}
关于生成1000个随机整数使用关于时间的seed种子创建随机数然后将其放入循环循环1000次`得到一千个随机整数.
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;
}
}
posted on 2023-09-22 17:57  汀幻  阅读(2)  评论(0编辑  收藏  举报