لدى مشكلة فى جلب قيم من دالة random حيث أننى أريد قيم من 5 الى 10مثلا يمكن عمل عليها فقط
انا وصلت لنتيجة بسيطة لوهناك اقتراح أفضل جزاكم الله خيرا
import java.util.Random;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author hema
*/
public class RandomINt {
public static void main(String[]aArgs){
int min=5;
int max=9;
System.out.println("Generating 10 random integers in range 0..99.");
Random rand=new Random();
for (int x=1;x<=5;x++){
int randomNum = rand.nextInt(max - min + 1) + min;
System.out.println(randomNum);
}
}
}