生成几个不相同的数字

    技术2022-05-20  68

    Random r = new Random();  int temp[] ={0,0,0,0,0,0,0,0,0,0};  String fourNum="";  while(fourNum.length()!=9){      int t = r.nextInt(9);      if(temp[t]==0){      fourNum+=t;      temp[t]=1;   }  }System.out.println(fourNum);


    最新回复(0)