I have just started learning Java and I need a random number generator. Can anyone help.
Sophie
I have just started learning Java and I need a random number generator. Can anyone help.
Sophie
simple is always an understatement.....
Do a search on java.lang.Math.random()
Also if your doing Java....take a look at Javaranch ...good forum...even if they are a bit "cowboy" obsessed
Another great java forum:
http://forum.java.sun.com
-MethodMan-
Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.
Homepage: http://www.freewebs.com/andy_moog/home.html
No offense meant, but last time I checked, this is a C, C++, C# board. Use the sun forums, please.
.
And this is a GD board, where anything that doesn't apply to the other boards can be discussed.
General Discussions. (Hmm, we dont ever discuss things here, do we?) Not a java help board. If we were to be discussing the pros and cons of java or something to that effect, then I wouldnt have said what I did, but she is asking for help on the General Discussions board.
Heh, we should get a general programming board for help on any languages that arent C, C++, C#.
Last edited by civix; 08-17-2002 at 06:23 PM.
.
Ehh, who cares? Let's not make this a *****ing match (made towards both of us, not just you).
>I have just started learning Java and I need a random number generator. Can anyone help.
Java has several ways to get a random number, the following being the easiest.
-PreludeCode:import java.util.*; import java.io.*; class RandTest { public static void main ( String args[] ) { int i; // Seed from the current system time. Random rand = new Random(); // Get a random number from 1 - 100. i = rand.nextInt ( 100 ) + 1; System.out.println ( "Your random number is: " + i ); } }
My best code is written with the delete key.