Java Random Int randInt(int range)

Here you can find the source of randInt(int range)

Description

generates a random integer value from 0 to (range-1)

License

Open Source License

Parameter

Parameter Description
range a parameter

Declaration

public static int randInt(int range) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2012 pf_miles./*from  w  w w .  j a va2s.co  m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     pf_miles - initial API and implementation
 ******************************************************************************/

public class Main {
    /**
     * generates a random integer value from 0 to (range-1)
     * 
     * @param range
     * @return
     */
    public static int randInt(int range) {
        return (int) (Math.random() * range);
    }
}

Related

  1. randInt(int min, int max)
  2. randInt(int n)
  3. randInt(int n)
  4. randInt(int n)
  5. randInt(int range)
  6. RandInt(int x, int y)
  7. randIntArray(int length)
  8. randIntArray(int length)
  9. randIntv(double fr, double to)