(Java) Generating Random Integer in Range
Demonstrates how to generate random integers in a specified range.
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
// All Chilkat classes can be unlocked at once at the beginning of a program
// by calling UnlockBundle. It requires a Bundle unlock code.
CkGlobal chilkatGlob = new CkGlobal();
boolean success = chilkatGlob.UnlockBundle("Anything for 30-day trial.");
if (success != true) {
System.out.println(chilkatGlob.lastErrorText());
return;
}
CkPrng fortuna = new CkPrng();
// Generate random integers between 12 and 24 inclusive
int i;
for (i = 0; i <= 100; i++) {
System.out.println(fortuna.RandomInt(12,24));
}
}
}
|