JAVA Program to generate random number

Hi Folks. My friend asked for a java program which can help in generating the random numbers bec...

Hi Folks. My friend asked for a java program which can help in generating the random numbers because he's writing some sort of game. Well, I'm not a big Java fan as I still love C\C++ to write codes however after writing a revolutionary code like Space Eater Virus in Java many friends suggested me to migrate from C language to Java. I left this decision on time as of now. In order to solve the problem of my buddy I randomly or you can say shamelessly got a code from internet which was written for the same purpose. Here I'm sharing that code.....

public class Random
    private static long seed = 13;
    private static long a;
    private static long c;
    private static long m;

    public static void random_init(long s) {
if (s != 0) seed = s;

    public static long random() {
seed = (a*seed + c)%m;
return seed;

    public static void main(String[] args) {
if (args.length != 4) {
   System.out.println("usage: you must enter values for a, c, m, seed");
a = Long.parseLong(args[0]);
c = Long.parseLong(args[1]);
m = Long.parseLong(args[2]);

long s = Long.parseLong(args[3]);
for (int k = 0; k < m-1; k++) {
   if (k % 8 == 7) { // after 8 elements go to a new line
try {
   Thread.sleep(1000); // sleep for a second
} catch (Exception e) {

If you're having troubles in compiling the code then take a look at How to Compile the JAVA Program.

Keep Coding. :) keep visiting   

android facebook free-zone Freebies hacking How-to programming scripts video whatsapp
Mr Tricks: JAVA Program to generate random number
JAVA Program to generate random number
Mr Tricks
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy