package lianxi;
public class Test1 {
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        //功能需求  求一个1000~9999之间的随机数
        int max = 9999;
        int min = 1000;
        
        //double random = Math.random();// 返回带正号的 double 值,该值大于等于 0.0 且小于 1.0。
//        System.out.println(random);
        
        int rand = (int) (Math.random()*(max-min)+min);
        System.out.println(rand);
    }
}
原文:http://www.cnblogs.com/siashan/p/3843928.html