|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | public static void main(String[] args) { | 
|---|
|  |  |  | System.out.println(CreateRandom.Random(1, 0)); | 
|---|
|  |  |  | System.out.println(CreateRandom.Random(2, 0)); | 
|---|
|  |  |  | System.out.println(CreateRandom.Random(3, 0)); | 
|---|
|  |  |  | System.out.println(CreateRandom.Random(4, 0)); | 
|---|
|  |  |  | System.out.println(CreateRandom.Random(5, 0)); | 
|---|
|  |  |  | System.out.println(CreateRandom.Random(100, 0)); | 
|---|
|  |  |  | System.out.println(CreateRandom.Random(1256, 1234)); | 
|---|
|  |  |  | //      System.out.println(CreateRandom.random(1, 0)); | 
|---|
|  |  |  | //      System.out.println(CreateRandom.random(2, 0)); | 
|---|
|  |  |  | //      System.out.println(CreateRandom.random(3, 0)); | 
|---|
|  |  |  | //      System.out.println(CreateRandom.random(4, 0)); | 
|---|
|  |  |  | //      System.out.println(CreateRandom.random(5, 0)); | 
|---|
|  |  |  | //      System.out.println(CreateRandom.random(100, 0)); | 
|---|
|  |  |  | //      System.out.println(CreateRandom.random(1256, 1234)); | 
|---|
|  |  |  | System.out.println("======================="); | 
|---|
|  |  |  | for(int i = 0 ; i < 100; i++){ | 
|---|
|  |  |  | System.out.println(create_between(10, 100)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | */ | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 4位随机数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | if(max - min < min/2){ | 
|---|
|  |  |  | return min ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String minStr = String.valueOf(min) ; | 
|---|
|  |  |  | int len = minStr.length() ; | 
|---|
|  |  |  | char minFirst = minStr.charAt(0) ; | 
|---|
|  |  |  | double d = Math.random(); | 
|---|
|  |  |  | d = d * 10000000 ; | 
|---|
|  |  |  | String s = String.valueOf(d); | 
|---|
|  |  |  | s = minFirst + s ; | 
|---|
|  |  |  | int len = String.valueOf(min).length() ; | 
|---|
|  |  |  | String s = String.valueOf(Math.random() * 10000000); | 
|---|
|  |  |  | s = s.substring(0 ,len) ; | 
|---|
|  |  |  | int n = Integer.parseInt(s) ; | 
|---|
|  |  |  | if(n < min || n > max){ | 
|---|