方法--动手又动脑 2018/10/14

(1)

 1 package test2;
 2 /*
 3  * 产生指定书目的随机整数
 4  * 杨瑞 2018/10/14
 5  */
 6 public class RandomTest {
 7  public static final int MAX=100; //MAX相当于常量
 8  public long a=12345L;
 9  public long c=12345L;
10  public long m=12365L;
11  public long x=1;
12  //随机数生成器
13  public long rand() {
14   x=(x*a+c)%m;
15   return x;
16  }
17  public static void main(String []args) {
18   
19   RandomTest s=new RandomTest();
20   long r;
21   for(int i=0;i<MAX;) {
22    r=s.rand();
23    System.out.print(r+" ");
24    i++;
25    if(i%10==0)
26     System.out.println();
27   }
28   
29  }
30 }
(2)我发现了这个方法用了重载的方法。

(3)我发现了这个方法也是用了重载的方法。

 
 
 
 
原文地址:https://www.cnblogs.com/qianmo123/p/9786786.html