/** * @author lautturi.com * Java example: random 6 digit number in java */ import java.util.*; public class Lautturi { public static void main(String args[]) { // It will generate 6 digit random Number. // from 0(inclusive) to 999999(exclusive) Random rnd = new Random(); int number = rnd.nextInt(999999); // this will convert any number sequence into 6 character. String str = String.format("%06d", number); } }