Here you can find the source of createRandomHexNumber(int length)
public static String createRandomHexNumber(int length)
//package com.java2s; /*//from www . j av a 2 s. c o m * Copyright (C) 2013 Maino * * This work is licensed under the Creative Commons * Attribution-NonCommercial-NoDerivs 3.0 Unported License. To view a copy of * this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or send * a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, * California, 94105, USA. * */ import java.util.*; public class Main { public static String createRandomHexNumber(int length) { Random random = new Random(System.currentTimeMillis()); char[] result = new char[length]; for (int i = 0; i < length; i++) { int r = random.nextInt(16); result[i] = Integer.toHexString(r).charAt(0); } return new String(result); } }