取一定范围内的随机数!

来源:互联网 发布:斗牛代码算法 编辑:程序博客网 时间:2024/05/04 16:31

//取5到100之间的随机数

public class Test
{
public static void main(String[] args)
{
int random = 5 + (int)(Math.random()*(100-5+1));
System.out.println(random);
}
}

原创粉丝点击