Java tutorial
//package com.java2s; import java.util.Random; public class Main { public static String getRandomUserId(int i) { Random random = new Random(); StringBuilder stringbuilder = new StringBuilder(i); int j = 0; do { if (j >= i) return stringbuilder.toString(); stringbuilder.append((char) (48 + random.nextInt(10))); j++; } while (true); } }