List of usage examples for java.lang Math random
public static double random()
From source file:Main.java
/** * Returns a random color./*from w ww .j av a2 s . co m*/ */ public static Color getRandColor() { return new Color((int) (Math.random() * 255), (int) (Math.random() * 255), (int) (Math.random() * 255)); }
From source file:Main.java
public static int getRandomNumber(int max) { if (max <= 0) return 0; int random = (int) (Math.random() * max + 1); return random; }
From source file:Main.java
public static String generateReplyID() { long l = System.currentTimeMillis(); return "RP" + String.valueOf(l) + String.valueOf((int) (1000.0D + Math.random() * 9000.0D)); }
From source file:Main.java
public static int[] getCheckNum() { int[] tempCheckNum = { 0, 0, 0, 0 }; for (int i = 0; i < 4; i++) { tempCheckNum[i] = (int) (Math.random() * 10); }// w w w. j a va2 s.c om return tempCheckNum; }
From source file:Main.java
public static String generateReplyID() { String str = String.valueOf(System.currentTimeMillis()); return "RP" + str + String.valueOf((int) (1000.0D + 9000.0D * Math.random())); }
From source file:Main.java
private static String getVirtualImei() { StringBuilder result = new StringBuilder("1234567"); for (int i = 0; i < 8; i++) { result.append((int) (Math.random() * 10)); }/*from w ww.jav a2 s. c o m*/ return result.toString(); }
From source file:Main.java
public static int[] getLine(int height, int width) { int[] tempCheckNum = { 0, 0, 0, 0 }; for (int i = 0; i < 4; i += 2) { tempCheckNum[i] = (int) (Math.random() * width); tempCheckNum[i + 1] = (int) (Math.random() * height); }//from ww w .jav a 2s . co m return tempCheckNum; }
From source file:Main.java
public static int[] getLine(int height, int width) { int[] tempCheckNum = { 0, 0, 0, 0, 0 }; for (int i = 0; i < 4; i += 2) { tempCheckNum[i] = (int) (Math.random() * width); tempCheckNum[i + 1] = (int) (Math.random() * height); }//from w ww .ja va2 s.co m return tempCheckNum; }
From source file:Main.java
public static long getRandomLong3() { Random rd = new Random(); long l2 = 0;//from w ww . ja va 2 s .co m l2 = (int) (Math.random() * 300); return l2; }
From source file:Main.java
public static int[] getCheckNum(int textlength) { int[] tempCheckNum = new int[textlength]; for (int i = 0; i < textlength; i++) { tempCheckNum[i] = (int) (Math.random() * 10); }//www . ja v a 2 s. co m return tempCheckNum; }