Back to project page XKCD-Reader.
The source code is released under:
Apache License
If you think the Android project XKCD-Reader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.davidtpate.xkcd.util; /* w w w . j av a 2 s .c o m*/ import java.util.Random; public class MathUtil { private static final Random mRandom = new Random(); /** * Returns a pseudo-random number between min and max, inclusive. * The difference between min and max can be at most * <code>Integer.MAX_VALUE - 1</code>. * * See http://stackoverflow.com/a/363692/1076683 for details. * * @param min Minimum value * @param max Maximum value. Must be greater than min. * @return Integer between min and max, inclusive. * @see java.util.Random#nextInt(int) */ public static int randInt(int min, int max) { // nextInt is normally exclusive of the top value, // so add 1 to make it inclusive int randomNum = mRandom.nextInt((max - min) + 1) + min; return randomNum; } }