Java Question

This is a discussion on Java Question within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I have just started learning Java and I need a random number generator. Can anyone help. Sophie...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    94

    Java Question

    I have just started learning Java and I need a random number generator. Can anyone help.

    Sophie
    simple is always an understatement.....

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    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

  3. #3
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    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

  4. #4
    Seven years? civix's Avatar
    Join Date
    Jul 2002
    Posts
    605
    No offense meant, but last time I checked, this is a C, C++, C# board. Use the sun forums, please.

  5. #5
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    And this is a GD board, where anything that doesn't apply to the other boards can be discussed.

  6. #6
    Seven years? civix's Avatar
    Join Date
    Jul 2002
    Posts
    605
    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.
    .

  7. #7
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Ehh, who cares? Let's not make this a *****ing match (made towards both of us, not just you).

  8. #8
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >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.
    Code:
    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 );
      }
    }
    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mats, the java answers
    By Jaqui in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-22-2008, 02:12 AM
  2. Java vs C to make an OS
    By WOP in forum Tech Board
    Replies: 59
    Last Post: 05-27-2007, 03:56 AM
  3. Windows GDI vs. Java Graphics
    By Perspective in forum Windows Programming
    Replies: 7
    Last Post: 05-07-2007, 10:05 AM
  4. How to use Java with C++
    By Arrow Mk 84 in forum C++ Programming
    Replies: 2
    Last Post: 02-27-2003, 03:12 PM
  5. A question for .. java!
    By McAuriel in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 12-01-2002, 10:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21