Android examples for java.util:Random
get Random Number
public class Main{ private static String getRandomNum(int length) { length = (length > 0) ? length : 10; StringBuffer sRand = new StringBuffer(); for (int i = 0; i < length; i++) { sRand.append((int) (Math.random() * 10)); }/*from w w w .j av a 2s . c om*/ return sRand.toString(); } }