取随机数

1、Random

  import java.util.Random;

  int i = new Random().nextInt(4);

2、Math

  int i = (int)(Math.random()*4);  //Math.random = [0, 1)

猜你喜欢

转载自www.cnblogs.com/ss-123/p/8973407.html