取随机数

1、Random

  import java.util.Random;

  int i = new Random().nextInt(4);  /* 0, 1, 2, 3 */

2、Math

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

posted on 2018-04-30 12:51  15767140984  阅读(116)  评论(0)    收藏  举报