Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: random number array

  1. #1
    Member
    Join Date
    Mar 2013
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default random number array

    I'm trying to write a method called randomInt that takes two integers,low and high, and that returns a random integer x so that low is less than or equal to x which is less than high.
    public static int randomInt (low, high) {
        int high=100;
        for (int low=0; low <= 100; low ++) {
            int i= random ();
            return i;
        }
    I don't know how to make it random .


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,619
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: random number array

    how to make it random
    Are you required to write the code that generates the random number
    or can you call one of the methods in an existing java class?

    If the latter, see the API doc for the Random class and also the Math class has a method.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Random number
    By Imran Ahmad in forum Java Theory & Questions
    Replies: 1
    Last Post: April 30th, 2012, 11:53 AM
  2. Generation of random number using random class
    By JavaPF in forum Java SE API Tutorials
    Replies: 1
    Last Post: December 7th, 2011, 04:46 PM
  3. How to returned random number to original number?
    By i4ba1 in forum Algorithms & Recursion
    Replies: 2
    Last Post: March 19th, 2011, 04:35 AM
  4. HELP. Random Number Between
    By Raymond Pittman in forum Java Theory & Questions
    Replies: 3
    Last Post: February 15th, 2011, 08:50 AM
  5. Generation of random number using random class
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: April 16th, 2009, 06:10 AM