Random number generation between specific interval.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    Random number generation between specific interval.

    Pleas make me understand the ......

    [code=java]
    Random r = new Random(1000);
    [/code]

    "1000" this parameter what does it signify?
    Please make me understand.
    I read the API, but didn't understand.

    Debasis Jana
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Random number generation between specific interval.

    Here is my code .... it takes time to generate.

    [code=java]
    import java.util.*;

    public class TestRandom
    {
    public static void main(String args[]){
    Random r = new Random();
    int start = 100, end = 200; //The random number will be between 100 and 200
    for(int i=0;i<10;){ //suppose here 10 numbers ll be generated
    int rand = r.nextInt();
    if(rand>100 && rand<200){
    System.out.prin tln(rand);
    i++;
    }
    }
    }
    }
    [/code]

    How can I solve this, please help!

    Debasis Jana

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by dmjpro
      Pleas make me understand the ......

      [code=java]
      Random r = new Random(1000);
      [/code]

      "1000" this parameter what does it signify?
      Please make me understand.
      I read the API, but didn't understand.

      Debasis Jana
      I got it from another API.
      Sorry for asking fake Question.
      Again, I am really sorry for that.

      Debasis Jana

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        Originally posted by dmjpro
        Here is my code .... it takes time to generate.

        [code=java]
        import java.util.*;

        public class TestRandom
        {
        public static void main(String args[]){
        Random r = new Random();
        int start = 100, end = 200; //The random number will be between 100 and 200
        for(int i=0;i<10;){ //suppose here 10 numbers ll be generated
        int rand = r.nextInt();
        if(rand>100 && rand<200){
        System.out.prin tln(rand);
        i++;
        }
        }
        }
        }
        [/code]

        How can I solve this, please help!

        Debasis Jana
        I got it worked.
        Just used .............
        [code=java]
        int rand = r.nextInt(200); //but it is not from negative value
        [/code]

        Again again I am really sorry for fake Question.

        Debasisi Jana

        Comment

        Working...