Java Random Byte rand(int bit)

Here you can find the source of rand(int bit)

Description

rand

License

Open Source License

Declaration

public static String rand(int bit) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Random;

public class Main {

    public static String rand(int bit) {
        if (bit < 1) {
            return "";
        }/*from  w  w  w.  j  ava  2  s.com*/

        Random random = new Random();
        Double randNumber = random.nextDouble();
        return randNumber.toString().split("\\.")[1].substring(0, bit);
    }
}

Related

  1. createRandomByte()
  2. generateRandomByte()
  3. rand(int lbound, int ubound)
  4. rand(int lo, int hi)
  5. rand(int lo, int hi)
  6. rand(int lo, int hi)