JAVA生成隨機數

2021-07-06 07:05:50 字數 527 閱讀 7168

*生成6位字母加數字的隨機數字,隨機數格式為(字母,數字,字母,數字,字母,數字)

string a = "", c, n;

for (int i = 0; i < 3; i++)

system.out.println(a);

*生成類似qq號碼的隨機id號碼

// 隨機4位數

int array = ;

random rand = new random();

for (int i = 10; i > 1; i--)

int rdmnum = 0;

for (int i = 0; i < 4; i++)

// 時間戳

******dateformat sf = new ******dateformat("hms");

string stpnum = sf.format(new date());

// 組合

string result = rdmnum + stpnum;

return result;

java 生成隨機數的

方式一 min math.random max 注意 math.random 返回值型別是double 方式二 random ra new random int random ra.nextint max nin 查閱api文件後得出,通過該方法可以得到不同資料型別的隨機值 nextboolean ...

Java基礎 生成隨機數

math.random 方法會產生0到1之間的浮點數。可以使用以下方法產生0到n的正整數 int random int math.random n 如何利用math.random 方法產生隨機乙個小寫字元呢?也就是產生97到122的隨機數,然後int轉char ascii碼 char random ...

隨機生成隨機數

現畫乙個command命令按鈕,進行貼上。private sub command1 click show me scale 0,0 18,8 me.auto redraw true me.draw mode 2 circle 3,4 3,vb red me.auto redraw false lin...