I have a scenario in a java web app, where a random hexadecimal value has to be generated. This value should be within a range of values specified by me. (The range of value
You can try this. As this works for me:
Random random = new Random(); int nextInt = random.nextInt(256*256*256); System.out.println(String.format("#%06x", nextInt));