Results 1 to 4 of 4
  1. #1
    mamoonrizwan is offline Member
    Join Date
    Apr 2011
    Posts
    19
    Rep Power
    0

    Default Testing whether a random number is positive

    import java.util.Random;
    public class TestingThePositivityOfANumber {
    public static void main(String args[]){

    Random random = new Random();
    int num = random.nextInt();
    if(num>0){

    System.out.println("num is greater than o ");
    }
    }
    }

  2. #2
    Solarsonic is offline Senior Member
    Join Date
    Mar 2011
    Posts
    261
    Rep Power
    4

    Default

    What errors do you get? Your code looks fine.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Did you have a question, or did you just want to display your coding skillz?

    db

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Quote Originally Posted by DarrylBurke View Post
    Did you have a question, or did you just want to display your coding skillz?

    db
    I believe the proper term is l337 h4ck3r 5k!115

Similar Threads

  1. Random Number Algorithm
    By javauserjava in forum New To Java
    Replies: 5
    Last Post: 04-06-2011, 12:32 AM
  2. generating random number between 0 and 1
    By sara12345 in forum New To Java
    Replies: 1
    Last Post: 04-17-2010, 07:54 PM
  3. Random number generater
    By kickflipper1087 in forum New To Java
    Replies: 6
    Last Post: 10-21-2008, 10:19 PM
  4. Random number help
    By jgonzalez14 in forum New To Java
    Replies: 5
    Last Post: 09-16-2008, 09:13 AM
  5. Random number
    By jithan in forum Advanced Java
    Replies: 1
    Last Post: 06-13-2008, 01:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •