List of usage examples for java.lang Math random
public static double random()
From source file:Main.java
/** * get nonce// ww w.j a v a2 s .co m * @return */ public static String getNonce() { int random = (int) (Math.random() * 9000) + 1000; return String.valueOf(random); }
From source file:Main.java
public static int randomColor() { return Color.argb(127, ((Long) Math.round(Math.random() * 255)).intValue(), ((Long) Math.round(Math.random() * 255)).intValue(), ((Long) Math.round(Math.random() * 255)).intValue()); }
From source file:Main.java
public static String randNum(long dig, long len) { String number;/*from w w w . j av a 2 s . co m*/ int num = (int) Math.abs((Math.round(Math.random() * dig) + len)); number = Integer.toString(num); return number; }
From source file:Main.java
public static int getPosition(int height) { int tempPosition = (int) (Math.random() * height); if (tempPosition < 1) { tempPosition += 1;/*from w w w . j a v a2 s .c o m*/ } return tempPosition; }
From source file:Main.java
/** A random int from 1 to range (inclusive). */ public static int randomInt(int range) { return (1 + ((int) (Math.random() * range))); }
From source file:Main.java
private static String generateNonce() { int max = 9999999; int min = 123400; double rand = Math.random(); //Return a string representation of a random value between the max and min return "" + (int) (min + (rand * ((max - min) + 1))); }
From source file:Main.java
public static int getTextPosition(int height) { int tempPosition = (int) (Math.random() * height); if (tempPosition < 0.5 * height) { tempPosition += 0.5 * height;/*w w w . j a v a 2s . c o m*/ } return tempPosition; }
From source file:Main.java
public static String randString() { String ret = ""; for (int i = 0; i < 6; i++) { int a = (int) (Math.random() * 10); ret += a;/*from w w w . j a v a 2 s .c o m*/ } return ret; }
From source file:Main.java
public static int[] getPoint(int height, int width) { int[] tempCheckNum = { 0, 0, 0, 0, 0 }; tempCheckNum[0] = (int) (Math.random() * width); tempCheckNum[1] = (int) (Math.random() * height); return tempCheckNum; }
From source file:Main.java
public static String getTransactionId() { String id = ""; for (int i = 0; i < 10; i++) { id = id + (int) (Math.random() * 9 + 1); }//from w ww . ja va 2s.c om return id; }