I need some help with java

Asked By 0 points N/A Posted on -
qa-featured

Hello friends ,

I want to create an array ,  which need to store randomly generated numbers in the range of 5483-400000 ,

  Can  anyone provide me with the java code?

SHARE
Answered By 0 points N/A #94102

I need some help with java

qa-featured

Hello Emerald,

I would like to start by telling you about the Random utility of Java, All you got to do is import it and create a function. Here is a sample part code that randomly generate numbers 5483 to 400000 and directly stored in an array..

 
import java.util.Random;
public final class number {
 
  public static final void main(String… aArgs){
    log("Generating 10 random integers in range 5483..400000.");
int min = 5483;
int max = 400000;
 
    Random random = new Random();
    for (int i = 1; i <= 10; ++i){
     //Generate a random number from 5483  to 400000
int randomNumber = random.nextInt(max – min) + min;
 
      log("Generated : " + randomNumber);
    }
 
    log("Done.");
  }
 
  private static void log(String aMessage){
    System.out.println(aMessage);
  }
}
 
Hope it help you, have a good day!..

Login/Register to Answer

Related Questions