One, random number
Import Java.util.Random;
public class Suijishu {
private static final int N = 200;
private static final int left = 40;
private static final int right = 10000;
private static long x0 = 1L;
Private long a = 1103515245L;
Private long C = 12345L;
Private long m = 2147483648L;
Generate random numbers
Private Long Rnd (long R) {
R = (R * A + C)% m;//xn+1= (aXn + c) MoD m
return R;
}
Private long Little1 (int a, int b, long rand) {
Return a+rand% (b-a+1);
}
private void recursion (int count, long rand) {
if (count >= N) {return;}
Rand = rand (RAND);
Long R = Little1 (left, right, Rand);
System.out.print (R + "");
Recursion (++count, Rand);
}
Private long Little (int left2, int right2, long rand) {
TODO auto-generated Method Stub
return 0;
}
public static void Main (string[] args) {
Suijishu recur = new Suijishu ();
Recur.recursion (0, x0);
}
}
Second, method overloading
public class Methodoverload {
public static void Main (string[] args) {
System.out.println ("The square of the 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;
}
}
Two or more methods that meet the following conditions form an "overloaded" relationship:
(1) The method name is the same;
(2) The parameter types are different, the number of parameters is different, or the order of the parameter types is different.
Note: The return value of the method is not used as a criterion for method overloading.
Basic work of Java grammar--hands-on brain and experimental problems after class (II.)