Java examples for java.lang:int
create Number Random
//package com.java2s; public class Main { public static final String ALL_NUMBER_VALUE = "0123456789"; public static String createNumberRandom(int length) { if (length < 1) { throw new IllegalArgumentException( "length cannot be less than 1"); }/* ww w. j av a2s . c om*/ int vLen = ALL_NUMBER_VALUE.length(); String result = ""; for (int i = 1; i <= length; i++) { double dr = Math.random() * vLen; int ir = (int) Math.floor(dr); result += ALL_NUMBER_VALUE.charAt(ir); } return result; } }