Sample code for 30+ languages & platforms
Java

Generating Random Integer in Range

See more PRNG Examples

Demonstrates how to generate random integers in a specified range.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.Prng;

public class ChilkatExample {

    public static void main(String[] args) {
        boolean success = false;

        // This example assumes the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        success = false;

        Prng fortuna = new Prng();

        // Generate random integers between 12 and 24 inclusive
        for (int i = 0; i <= 100; i++) {
            System.out.println(fortuna.randomInt(12, 24));
        }
    }
}