Java Random Int randomIntWithDigits(int digits)

Here you can find the source of randomIntWithDigits(int digits)

Description

random Int With Digits

License

Apache License

Declaration

public static int randomIntWithDigits(int digits) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int randomIntWithDigits(int digits) {
        int max = (int) Math.pow(10, digits) + 1;
        return randomIntWithMinMax(0, max);
    }//from w w w . j  a va2  s  .c  om

    public static int randomIntWithMinMax(int min, int max) {
        return (int) (min + (Math.random() * (max - min + 1)));
    }
}

Related

  1. randomIntFromInterval(int min, int max)
  2. randomIntFromRange(int min, int max)
  3. randomIntInInterval(int lower, int upper)
  4. randomIntInRange(int lowerBound, int upperBound)
  5. randomIntRange(int low, int high)
  6. randomKey(int sLen)
  7. randomMatrix(int x, int y)
  8. randomModuleName(int count)
  9. randomNum(int n)