Friday, March 9, 2012

Randomising :)

Hi!
One of the things I like most in Java, is Random. I like it because I can make it do anything! Here is the code of a basic randomizer! CODE:

import java.util.Random;                           // imports the Random number generator

class randomizer {

public static void main(String args[]) {
Random rn = new Randon();                    
int random;

random = rn.nextInt(10);                          // tells the compiler, in what range of number shoud it generate.
System.out.println(random);                     // displays the number

    }
}

This is a simple code. But you can use the if , to make it more enchanced!