Create random numbers in a range


package de.eknori.common;

public class Randomizer {

	public Randomizer() {

	}

	/***
	 * @param min
	 * @param max
	 * @return
	 */
	public static int generate(int min, int max) {
		return min + (int) (Math.random() * ((max - min) + 1));
	}
}
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
1 comment(s)Login first to comment...
Alice Smith
(at 04:54 on 27.09.2017)
This is a good solution if the change of the random generator returning a valid number.
<a href="https://www.paisa.co/home-loan">https://www.paisa.co/home-loan</a>