⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e331. generating a random number.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
Random rand = new Random();
    
    // Random integers
    int i = rand.nextInt();
    // Continually call nextInt() for more random integers ...
    
    // Random integers that range from from 0 to n
    int n = 10;
    i = rand.nextInt(n+1);
    
    // Random bytes
    byte[] bytes = new byte[5];
    rand.nextBytes(bytes);
    
    // Other primitive types
    boolean b = rand.nextBoolean();
    long l = rand.nextLong();
    float f = rand.nextFloat();     // 0.0 <= f < 1.0
    double d = rand.nextDouble();   // 0.0 <= d < 1.0
    
    
    // Create two random number generators with the same seed
    long seed = rand.nextLong();
    rand = new Random(seed);
    Random rand2 = new Random(seed);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -