Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[JAVA][SNIPPET]Random Number Generation - HackCommunity Exclusive filter_list
Author
Message
[JAVA][SNIPPET]Random Number Generation - HackCommunity Exclusive #1
If you guys have seen my recent thread, I have started learning Java Programming and thus far, am loving it!

This is my first Java Snippet release and what this is, is a Random Number Generator.

NOTE: THIS IS ONLY A SOURCE, SO YOU MUST HAVE A COMPILER OF YOUR OWN TO RUN/USE

The file MUST BE NAME "RandomNumGen.java" for it to compile
Code:
//Brought to you by Jacob - Hackcommunity.com - The Best Ethical Hacking Forums
//                           Come pay us a visit!
//Bare with me, i've just started learning Java Programming :)
//This is my first Java Snippet Release :D

import java.util.Random;

class RandomNumGen{
    public static void main(String[] args){
            Random random = new Random();
            int max = 4; //This is where you will replace the 0 with the MAXIMUM number you would like to generate
            int amount = 10; //This is where you will replace the 10 with the AMOUNT of numbers you would like to generate
            int out;
            
            for(int counter = 1; counter <= amount;counter++){
                out = 1+random.nextInt(max);
                System.out.println(out + " ");
            }
        }
    }

Reply





Messages In This Thread
[JAVA][SNIPPET]Random Number Generation - HackCommunity Exclusive - by Jacob - 02-10-2012, 11:20 AM



Users browsing this thread: 1 Guest(s)