Java Generate Random Number

By gilbitron in Java on 23/02/2009 at 06:35

Views: 485
Tagged: java

Main Course:

/**
* For generating a random number, from 0 to max
*/
public static int generateNumber(int max)
{
	return (int)( Math.ceil(Math.random() * max ) - 1) ;
}

Expand Report Code | Install Coda Clip

Please log in to vote.

Compliments to the Chef

No comments yet...

How was your Meal?


  • Allowed HTML: <b><strong><u><i><em><a>

  • Why ask? It helps us stop spam comments.