码迷,mamicode.com
首页 > 其他好文 > 详细

Math.random()练习

时间:2017-09-16 21:54:39      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:math   index   stat   array   new   system   print   length   static   

package Sep_16;

public class Array {
public static void main(String[] args) {
String a[]=new String[]{"张三","李四","王五","赵六","鬼脚七"};
System.out.println(a[(int) (Math.random()*a.length)]);


int []array={2,35,26,754,358,346,906,356,14,89,};
double b=Math.random();
double c=Math.random()*array.length;
int index=(int) (Math.random()*array.length);
System.out.println(array[index]);


}
}

Math.random()练习

标签:math   index   stat   array   new   system   print   length   static   

原文地址:http://www.cnblogs.com/wanghusuoyi/p/7532856.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!