Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2009 Wilfred Springer Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package nl.flotsam.xeger;
Potentially a huge collection of utilities; now limited to only one method.
public class XegerUtils {

Generates a random number within the given bounds.

min The minimum number (inclusive).
max The maximum number (inclusive).
random The object used as the randomizer.
A random number in the given range.
    public final static int getRandomInt(int minint maxRandom random) {
        int dif = max - min;
        float number = random.nextFloat();              // 0 <= number < 1
        return min + Math.round(number * dif);
New to GrepCode? Check out our FAQ X