1. 程式人生 > >Math.random()練習

Math.random()練習

pri and str index double pub string math ack

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()練習